#include <bits/stdc++.h>
using namespace std;
map<unsigned long long, unsigned long long> mp;
unsigned long long cur = 1;
unsigned long long dob(unsigned long long x) {
  if (mp[x] == 0) {
    mp[x] = cur;
    cur++;
  }
  return mp[x];
}
vector<vector<unsigned long long>> z(2e5);
vector<unsigned long long> used(2e5, 0), bused(2e5, 0);
vector<unsigned long long> siz(2e5, 0);
const unsigned long long inf = 1e14;
unsigned long long ans = inf;
void dfs(unsigned long long v, unsigned long long p = inf,
         unsigned long long sz = 0) {
  used[v] = 1;
  siz[v] = sz;
  bused[v] = 1;
  for (unsigned long long i = 0; i < z[v].size(); ++i) {
    unsigned long long to = z[v][i];
    if (to == p) continue;
    if (used[to] && sz + 1 >= 3 + siz[to]) ans = min(ans, sz + 1 - siz[to]);
    if (!used[to]) dfs(to, v, sz + 1);
  }
  siz[v] = 0;
  used[v] = 0;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n;
  cin >> n;
  vector<unsigned long long> g[100];
  for (unsigned long long i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    unsigned long long x = a;
    for (unsigned long long k = 0; k < 63; ++k) {
      if ((x & (1ull << k)) > 0) g[k].push_back(x);
    }
  }
  for (unsigned long long i = 0; i < 100; ++i) {
    if (g[i].size() >= 3) {
      cout << 3;
      return 0;
    }
    if (g[i].size() == 2) {
      unsigned long long x = g[i][0];
      unsigned long long y = g[i][1];
      z[dob(x)].push_back(dob(y));
      z[dob(y)].push_back(dob(x));
    }
  }
  for (unsigned long long i = 0; i < 2e5; ++i) {
    if (!bused[i]) dfs(i);
  }
  if (ans == inf)
    cout << -1;
  else
    cout << (long long)ans;
  return 0;
}
