#include<bits/stdc++.h>
#define T long long t;cin >>t;while(t--)
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define lll unsigned long long
using namespace std;
void Abady(){
int x; cin >> x;
int arr[x];
bool b=0;
int e=0,o=0;
for (int i=0;i<x;i++){
cin >> arr[i];
if (arr[i]&1^1){
e = __gcd(e,arr[i]);
}
else {
o = __gcd(o,arr[i]);
}
}
if (__gcd(e,o)==1) cout << x << endl;
else cout << -1 << endl;
}
int main(){
fast;
Abady();
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBUIGxvbmcgbG9uZyB0O2NpbiA+PnQ7d2hpbGUodC0tKQojZGVmaW5lIGZhc3QgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOyBjaW4udGllKDApOyBjb3V0LnRpZSgwKQojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIGxsbCB1bnNpZ25lZCBsb25nIGxvbmcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZvaWQgQWJhZHkoKXsKICAgIGludCB4OyBjaW4gPj4geDsKICAgIGludCBhcnJbeF07CiAgICBib29sIGI9MDsKICAgIGludCBlPTAsbz0wOwogICAgZm9yIChpbnQgaT0wO2k8eDtpKyspewogICAgICAgIGNpbiA+PiBhcnJbaV07CiAgICAgICAgaWYgKGFycltpXSYxXjEpewogICAgICAgICAgICBlID0gX19nY2QoZSxhcnJbaV0pOwogICAgICAgIH0KICAgICAgICBlbHNlIHsKICAgICAgICAgICAgbyA9IF9fZ2NkKG8sYXJyW2ldKTsKICAgICAgICB9CiAgICB9CiAgICBpZiAoX19nY2QoZSxvKT09MSkgY291dCA8PCB4IDw8IGVuZGw7CiAgICBlbHNlIGNvdXQgPDwgLTEgPDwgZW5kbDsKfQppbnQgbWFpbigpewogICAgZmFzdDsKICAgIEFiYWR5KCk7Cn0KCg==