#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cassert>
using namespace std;
#define sz(a) int((a).size())
#define rep(i, s, n) for(int i = s; i <= (n); ++i)
#define rev(i, n, s) for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 1000005;
int a[N];
int b[N];
int n;
int go() {
int ans = -1;
rep(step, 0, 3) {
rep(i, 1, n) {
b[i] = a[i];
}
int cur = 0;
if(step & 1) {
cur++;
b[1] ^= 1;
b[2] ^= 1;
}
if((step / 2) & 1) {
cur++;
b[n] ^= 1;
b[n - 1] ^= 1;
}
rep(i, 1, n - 2) {
if(b[i]) {
b[i] ^= 1;
b[i + 1] ^= 1;
b[i + 2] ^= 1;
cur++;
}
}
if(b[n] == 0 && (n == 1 || b[n - 1] == 0)) {
if(ans == -1) {
ans = cur;
} else {
ans = min(ans, cur);
}
}
}
return ans;
}
int main() {
#ifdef loc
if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
assert(0);
}
freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
rep(i, 1, n) {
cin >> a[i];
a[i] &= 1;
}
int ans1 = go();
rep(i, 1, n) {
a[i] ^= 1;
}
int ans2 = go();
cout << ans2 << " " << ans1 << endl;
return 0;
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGxpc3Q+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDxkZXF1ZT4KI2luY2x1ZGUgPHF1ZXVlPgojaW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EpIHsKICAgICAgY3VyKys7CiAgICAgIGJbMV0gXj0gMTsKICAgICAgYlsyXSBePSAxOwogICAgfQogICAgaWYoKHN0ZXAgLyAyKSAmIDEpIHsKICAgICAgY3VyKys7CiAgICAgIGJbbl0gXj0gMTsKICAgICAgYltuIC0gMV0gXj0gMTsKICAgIH0KICAgIHJlcChpLCAxLCBuIC0gMikgewogICAgICBpZihiW2ldKSB7CiAgICAgICAgYltpXSBePSAxOwogICAgICAgIGJbaSArIDFdIF49IDE7CiAgICAgICAgYltpICsgMl0gXj0gMTsKICAgICAgICBjdXIrKzsKICAgICAgfQogICAgfQogICAgaWYoYltuXSA9PSAwICYmIChuID09IDEgfHwgYltuIC0gMV0gPT0gMCkpIHsKICAgICAgaWYoYW5zID09IC0xKSB7CiAgICAgICAgYW5zID0gY3VyOwogICAgICB9IGVsc2UgewogICAgICAgIGFucyA9IG1pbihhbnMsIGN1cik7CiAgICAgIH0KICAgIH0KICB9CiAgcmV0dXJuIGFuczsKfQoKaW50IG1haW4oKSB7CiNpZmRlZiBsb2MKICBpZighZnJlb3Blbigoc3RyaW5nKEZPTERFUikgKyAiaW5wLnR4dCIpLmNfc3RyKCksICJyIiwgc3RkaW4pKSB7CiAgICBhc3NlcnQoMCk7CiAgfQogIGZyZW9wZW4oKHN0cmluZyhGT0xERVIpICsgIm91dC50eHQiKS5jX3N0cigpLCAidyIsIHN0ZG91dCk7CiNlbmRpZgogIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgY2luLnRpZSgwKTsKICBjb3V0LnRpZSgwKTsKICBjaW4gPj4gbjsKICByZXAoaSwgMSwgbikgewogICAgY2luID4+IGFbaV07CiAgICBhW2ldICY9IDE7CiAgfQogIGludCBhbnMxID0gZ28oKTsKICByZXAoaSwgMSwgbikgewogICAgYVtpXSBePSAxOwogIH0KICBpbnQgYW5zMiA9IGdvKCk7CiAgY291dCA8PCBhbnMyIDw8ICIgIiA8PCBhbnMxIDw8IGVuZGw7CiAgcmV0dXJuIDA7Cn0=
Main.java:1: error: illegal character: '#'
#include <vector>
^
Main.java:1: error: class, interface, or enum expected
#include <vector>
^
Main.java:2: error: illegal character: '#'
#include <list>
^
Main.java:3: error: illegal character: '#'
#include <map>
^
Main.java:4: error: illegal character: '#'
#include <set>
^
Main.java:5: error: illegal character: '#'
#include <deque>
^
Main.java:6: error: illegal character: '#'
#include <queue>
^
Main.java:7: error: illegal character: '#'
#include <stack>
^
Main.java:8: error: illegal character: '#'
#include <bitset>
^
Main.java:9: error: illegal character: '#'
#include <algorithm>
^
Main.java:10: error: illegal character: '#'
#include <functional>
^
Main.java:11: error: illegal character: '#'
#include <numeric>
^
Main.java:12: error: illegal character: '#'
#include <utility>
^
Main.java:13: error: illegal character: '#'
#include <sstream>
^
Main.java:14: error: illegal character: '#'
#include <iostream>
^
Main.java:15: error: illegal character: '#'
#include <iomanip>
^
Main.java:16: error: illegal character: '#'
#include <cstdio>
^
Main.java:17: error: illegal character: '#'
#include <cmath>
^
Main.java:18: error: illegal character: '#'
#include <cstdlib>
^
Main.java:19: error: illegal character: '#'
#include <cctype>
^
Main.java:20: error: illegal character: '#'
#include <string>
^
Main.java:21: error: illegal character: '#'
#include <cstring>
^
Main.java:22: error: illegal character: '#'
#include <cstdio>
^
Main.java:23: error: illegal character: '#'
#include <cmath>
^
Main.java:24: error: illegal character: '#'
#include <cstdlib>
^
Main.java:25: error: illegal character: '#'
#include <ctime>
^
Main.java:26: error: illegal character: '#'
#include <fstream>
^
Main.java:27: error: illegal character: '#'
#include <cassert>
^
Main.java:30: error: illegal character: '#'
#define sz(a) int((a).size())
^
Main.java:30: error: class, interface, or enum expected
#define sz(a) int((a).size())
^
Main.java:31: error: illegal character: '#'
#define rep(i, s, n) for(int i = s; i <= (n); ++i)
^
Main.java:31: error: class, interface, or enum expected
#define rep(i, s, n) for(int i = s; i <= (n); ++i)
^
Main.java:31: error: class, interface, or enum expected
#define rep(i, s, n) for(int i = s; i <= (n); ++i)
^
Main.java:32: error: illegal character: '#'
#define rev(i, n, s) for(int i = (n); i >= s; --i)
^
Main.java:32: error: class, interface, or enum expected
#define rev(i, n, s) for(int i = (n); i >= s; --i)
^
Main.java:32: error: class, interface, or enum expected
#define rev(i, n, s) for(int i = (n); i >= s; --i)
^
Main.java:33: error: illegal character: '#'
#define fore(x, a) for(auto &&x : a)
^
Main.java:35: error: class, interface, or enum expected
const int mod = 1000000007;
^
Main.java:36: error: class, interface, or enum expected
const int N = 1000005;
^
Main.java:38: error: class, interface, or enum expected
int a[N];
^
Main.java:39: error: class, interface, or enum expected
int b[N];
^
Main.java:40: error: class, interface, or enum expected
int n;
^
Main.java:42: error: class, interface, or enum expected
int go() {
^
Main.java:44: error: class, interface, or enum expected
rep(step, 0, 3) {
^
Main.java:47: error: class, interface, or enum expected
}
^
Main.java:49: error: class, interface, or enum expected
if(step & 1) {
^
Main.java:51: error: class, interface, or enum expected
b[1] ^= 1;
^
Main.java:52: error: class, interface, or enum expected
b[2] ^= 1;
^
Main.java:53: error: class, interface, or enum expected
}
^
Main.java:56: error: class, interface, or enum expected
b[n] ^= 1;
^
Main.java:57: error: class, interface, or enum expected
b[n - 1] ^= 1;
^
Main.java:58: error: class, interface, or enum expected
}
^
Main.java:62: error: class, interface, or enum expected
b[i + 1] ^= 1;
^
Main.java:63: error: class, interface, or enum expected
b[i + 2] ^= 1;
^
Main.java:64: error: class, interface, or enum expected
cur++;
^
Main.java:65: error: class, interface, or enum expected
}
^
Main.java:70: error: class, interface, or enum expected
} else {
^
Main.java:72: error: class, interface, or enum expected
}
^
Main.java:76: error: class, interface, or enum expected
}
^
Main.java:79: error: illegal character: '#'
#ifdef loc
^
Main.java:82: error: class, interface, or enum expected
}
^
Main.java:84: error: illegal character: '#'
#endif
^
Main.java:85: error: class, interface, or enum expected
ios_base::sync_with_stdio(0);
^
Main.java:86: error: class, interface, or enum expected
cin.tie(0);
^
Main.java:87: error: class, interface, or enum expected
cout.tie(0);
^
Main.java:88: error: class, interface, or enum expected
cin >> n;
^
Main.java:89: error: class, interface, or enum expected
rep(i, 1, n) {
^
Main.java:91: error: class, interface, or enum expected
a[i] &= 1;
^
Main.java:92: error: class, interface, or enum expected
}
^
Main.java:94: error: class, interface, or enum expected
rep(i, 1, n) {
^
Main.java:96: error: class, interface, or enum expected
}
^
Main.java:98: error: class, interface, or enum expected
cout << ans2 << " " << ans1 << endl;
^
Main.java:99: error: class, interface, or enum expected
return 0;
^
Main.java:100: error: class, interface, or enum expected
}
^
74 errors