#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int INF = 1e9 + 7;
long long a[N];
int n;
vector<int> G[N];
vector<bool> valid[N];
void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}
int d[N];
int dist(int s, int t) {
  fill(d, d + n, INF);
  d[s] = 0;
  queue<int> que;
  que.push(s);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int i = 0; i < G[v].size(); i++) {
      int u = G[v][i];
      if (valid[v][i] && d[u] == INF) {
        d[u] = d[v] + 1;
        if (u == t) return d[u];
        que.push(u);
      }
    }
  }
  return d[t];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld", a + i);
  for (int k = 0; k < 63; k++) {
    vector<int> vs;
    for (int i = 0; i < n; i++) {
      if (a[i] >> k & 1) vs.push_back(i);
      if (vs.size() == 3) return puts("3"), 0;
    }
    if (vs.size() == 2) {
      add_edge(vs[0], vs[1]);
    }
  }
  int ans = INF;
  for (int i = 0; i < n; i++) {
    sort(G[i].begin(), G[i].end());
    G[i].resize(unique(G[i].begin(), G[i].end()) - G[i].begin());
    valid[i] = vector<bool>(G[i].size(), true);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < valid[i].size(); j++) {
      valid[i][j] = false;
      ans = min(ans, dist(i, G[i][j]) + 1);
      valid[i][j] = true;
    }
  if (ans < INF)
    printf("%d\n", ans);
  else
    puts("-1");
}
