#include <bits/stdc++.h>
using namespace std;
const int maxN = 100000 + 5;
const int maxE = 60 + 5;
const int INF = 0x3f3f3f3f;
int head[maxN], nxt[maxE * 2], to[maxE * 2], p[5], d[maxN];
long long a[maxN];
int tot, tot2;
struct Edge {
  int u, v;
} e[maxE];
queue<int> que;
set<pair<int, int> > s;
void link(int u, int v) {
  nxt[++tot] = head[u];
  head[u] = tot;
  to[tot] = v;
}
void BFS(int S, int T) {
  memset(d, 0x3f, sizeof(d));
  d[S] = 0;
  que.push(S);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int e = head[u]; e; e = nxt[e]) {
      int v = to[e];
      if (d[v] < INF) continue;
      if (u == S && v == T || u == T && v == S) continue;
      d[v] = d[u] + 1;
      que.push(v);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  long long mx = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d", &a[i]);
    mx = max(a[i], mx);
  }
  for (int i = 0; (1LL << i) <= mx; ++i) {
    int cnt = 0;
    for (int j = 1; j <= n; ++j)
      if ((1LL << i) & a[j]) {
        p[++cnt] = j;
        if (cnt >= 3) {
          printf("3\n");
          return 0;
        }
      }
    if (cnt == 2) {
      if (s.find(make_pair(p[1], p[2])) != s.end()) continue;
      s.insert(make_pair(p[1], p[2]));
      link(p[1], p[2]);
      link(p[2], p[1]);
      e[++tot2].u = p[1];
      e[tot2].v = p[2];
      s.insert(make_pair(p[1], p[2]));
    }
  }
  int ans = 61;
  for (int i = 1; i <= tot2; ++i) {
    int u = e[i].u, v = e[i].v;
    BFS(u, v);
    if (d[v] < INF) ans = min(d[v] + 1, ans);
  }
  if (ans == 61) ans = -1;
  printf("%d\n", ans);
  return 0;
}
