#include <bits/stdc++.h>
using namespace std;

int main () {
int n; cin >> n; vector<int>v(n); for(int &b : v) cin >> b; int s = 0; for(int b : v) s ^= b; int sc = 0; for(int b : v) sc ^= (b - 1); if(s == 0) { cout << "0" << endl; } else if(sc == 0) { cout << n << endl; } else cout << "-1" << endl; }