/**
* written by Binoy Barman .
**/
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifdef LOCAL
#include "unravel.hpp"
#else
#define dbg(...) 42
#endif
#define ll long long
int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll n, sum = 0, cnt = 0;
cin >> n;
vector<ll> a(n);
for(auto &x : a) cin >> x, sum += x;
if(sum & 1) {
cout << -1 << nl;
return 0;
}
for (int i = 0; i < n; i++) {
sum += a[i];
if(sum % 2 == 0) {
sum = 0;
cnt++;
}
}
cout << cnt << nl;
return 0;
}