#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
const int mod = 1e9 + 7;
void solve(){
int n;
cin >> n;
vector<int> v(n);
for (int i=0; i<n; i++){
cin >> v[i];
}
int cnt = 0;
bool flag = 1;
bool first = 1;
for (int i=0; i<n; i++){
if ((v[i] % 2 == 0) and (flag))
cnt++;
if ((v[i] % 2 != 0) and (first)){
flag = 0;
first = 0;
continue;
}
if ((v[i] % 2 != 0) and (!first)){
flag = 1;
first = 1;
cnt++;
}
}
(flag) ? cout << cnt << endl : cout << -1 << endl;
}
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
//cin >> t;
while(t--){
solve();
}
}