#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define endl '\n'
#define Endl '\n'
using namespace std;
const int N = 2e5 + 5;
int tc, n, m, a[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); // cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
long long sum = accumulate(a, a + n, 0ll);
if (sum & 1) {
cout << -1 << endl;
} else {
int cnt = 0;
sum = 0;
for (int i = 0; i < n; i++) {
sum += a[i];
if (sum % 2 == 0) {
cnt++;
sum = 0;
}
}
cout << cnt << endl;
}
return 0;
}