#include <bits/stdc++.h>
using namespace std;
long long e[122][122], f[122][122], q[122][5], n, x, g, num;
map<long long, long long> nn;
bool flag = false;
void addedge(int u, int v) {
  if (u > v) swap(u, v);
  e[u][v] = e[v][u] = 1;
  f[u][v] = f[v][u] = 1;
}
void check(long long x) {
  long long y = 0;
  y = (long long)(log2(x & (-x)));
  x >>= y;
  for (int i = y + 1; i <= 64;) {
    if (!x) return;
    if (x & 1) {
      if (!nn[num]) nn[num] = ++g;
      if (q[i][1]) {
        if (q[i][2]) {
          flag = true;
          cout << "3\n";
          return;
        }
        q[i][2] = nn[num];
        addedge(nn[num], q[i][1]);
      } else
        q[i][1] = nn[num];
    }
    x >>= 1;
    i++;
    if (!x) return;
    y = (long long)(log2(x & (-x)));
    i += y;
    x >>= y;
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= 120; i++)
    for (int j = 1; j <= 120; j++)
      if (i != j) e[i][j] = 1e8;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    num = i;
    check(x);
    if (flag) return 0;
  }
  long long ans = 1e8;
  for (int k = 1; k <= g; k++) {
    for (int i = 1; i <= g; i++)
      for (int j = i + 1; j <= g; j++) {
        if (f[k][i] && f[k][j]) {
          ans = min(e[i][j] + 2, ans);
        }
      }
    for (int i = 1; i <= g; i++)
      for (int j = 1; j <= g; j++) {
        e[i][j] = min(e[i][k] + e[k][j], e[i][j]);
      }
  }
  if (ans == 1e8)
    cout << "-1\n";
  else
    cout << ans << endl;
  return 0;
}
