#include <bits/stdc++.h>
using namespace std;
const int N = 150, M = 65;
int n;
int dist[N][N], g[N][N];
vector<long long> v[M];
map<long long, int> mp;
int main() {
  memset(g, 0x3f, sizeof g);
  memset(dist, 0x3f, sizeof dist);
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long t, x;
    cin >> x;
    t = x;
    int cnt = 0;
    while (t) {
      if (t & 1) v[cnt].push_back(x);
      t >>= 1;
      cnt++;
    }
  }
  int cnt = 0;
  bool flag = false;
  for (int i = 0; i <= 64; i++) {
    int m = v[i].size();
    if (!m)
      continue;
    else if (m > 2) {
      flag = true;
      break;
    } else if (m == 2) {
      long long x = v[i][0], y = v[i][1];
      if (!mp[x]) mp[x] = ++cnt;
      if (!mp[y]) mp[y] = ++cnt;
      x = mp[x], y = mp[y];
      g[x][y] = g[y][x] = 1;
      dist[x][y] = dist[y][x] = 1;
    }
  }
  if (flag)
    cout << 3 << endl;
  else {
    int res = 0x3f3f3f3f;
    for (int k = 1; k <= cnt; k++) {
      for (int i = 1; i < k; i++)
        if (g[k][i] == 1)
          for (int j = i + 1; j < k; j++)
            if (g[k][j] == 1)
              if (dist[i][j] != 0x3f3f3f3f)
                res = min(res, dist[i][j] + g[i][k] + g[j][k]);
      for (int i = 1; i <= cnt; i++)
        if (dist[i][k] != 0x3f3f3f3f)
          for (int j = 1; j <= cnt; j++)
            if (dist[k][j] != 0x3f3f3f3f)
              dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
    if (res != 0x3f3f3f3f)
      cout << res << endl;
    else
      cout << -1 << endl;
  }
}
