#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int,int>>
#define pb push_back
#define ts to_string
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b) / gcd(a,b)
#define srt(v) sort(v.begin(), v.end())
#define all(v) v.begin(), v.end()
#define rev(v) reverse(all(v))
#define cinv(v) for(auto it : v) cin >> it;
#define coutv(v) for(auto it : v) cout << it << ' '; cout << endl;
#define maxv(v) max_element(all(v))
#define minv(v) min_element(all(v))
#define F first
#define S second
#define pii pair<int,int>
const ll MOD = 1e9+7;
const int N = 1e5+10;
int hash[N];
ll bigMod(ll a, ll b, ll mod = 1e9+7) {
if(b == 0) return 1 % mod;
ll ans = bigMod(a, b / 2, mod);
ans = (ans * ans) % mod;
if(b % 2 == 1) ans = (ans * a) % mod;
return ans;
}
bool neg(vl v) {
for(int num : v) {
if(num >= 0) {
return false;
}
}
return true;
}
ll maxSubarraySum(vl v, ll n) {
ll sum = 0, mx = LONG_MIN;
for(ll i = 0; i < n; ++i) {
sum += v[i];
if(sum > mx) mx = sum;
if(sum < 0) sum = 0;
}
return mx;
}
vl div(ll n) {
vl v;
for(ll i = 1; i <= sqrt(n); ++i) {
if(n % i == 0) {
if(n / i == i) v.pb(i);
else {
v.pb(i);
v.pb(n / i);
}
}
}
return v;
}
int cnt(int a) {
int x = 0;
while(a != 0) {
a = a & a - 1;
x++;
}
return x;
}
ll ans(ll a, ll b, ll c){
ll aa = a;
a += max(0LL, b - a + 1);
a += max(0LL, c - a + 1);
return a - aa;
}
void fastIO() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
void raju_sir_is_love() {
int n;
cin >> n;
vl a(n);
for(int i = 0; i < n; ++i) {
cin >> a[i];
}
ll c = 0, sum = 0;
for(int i = 0; i < n; ++i) {
if(a[i] % 2 == 0) c++;
else {
sum += a[i];
if(sum % 2 == 0) {
c++;
sum = 0;
}
}
}
if(sum % 2 != 0) cout << -1 << endl;
else cout << c << endl;
return;
}
int main() {
fastIO();
read:
/*ll t;
cin >> t;
while(t--) {
raju_sir_is_love();
}*/
raju_sir_is_love();
return 0;
}