#include<bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin>>n;
long long int a[n];
for (int i = 0; i < n; ++i) {
cin>>a[i];
}
int flag=0;
long long int count=0;
long long int sum=0;
for (int i = 0; i < n; ++i) {
sum+=a[i];
// cout<<sum<<" sum"<<endl;
if (sum%2==0){
flag++;
count++;
// cout<<count<<" count"<<endl;
sum=0;
}
else flag=0;
}
for (int i = 0; i < n; ++i) {
sum=sum+a[i];
}
if (flag==0 and sum%2==1) {
cout << -1 << endl;
}
else if (sum%2==0) cout<<1<<endl;
else {
cout << count;
}
return 0;
}