#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();
}

