#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433;
const long long M = 998244353;
long long n, x, t, p, ans = 1e18;
bitset<61> b;
vector<long long> v[65];
map<long long, bool> m;
map<long long, long long> c;
void dfs(long long u, long long k, bitset<61> bb) {
  c[u] = k;
  if (u == p) {
    if (k > 1) ans = min(ans, k + 1);
  } else {
    m[u] = true;
    for (long long i = 0; i < 61; i++) {
      if (bb[i] == 1) {
        for (auto j : v[i]) {
          if (!m[j] || c[j] > k + 1) {
            b &= 0;
            b |= j;
            dfs(j, k + 1, b);
          }
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    b &= 0;
    b |= x;
    for (long long j = 0; j < 61; j++)
      if (b[j] == 1) {
        v[j].push_back(x);
        if (v[j].size() == 3) return cout << 3, 0;
      }
  }
  for (long long i = 0; i < 61; i++) {
    if (v[i].size() == 2) {
      m.clear();
      c.clear();
      t = v[i][0];
      p = v[i][1];
      b &= 0;
      b |= t;
      dfs(t, 0, b);
    }
  }
  if (ans == 1e18)
    cout << -1;
  else
    cout << ans;
}
