#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e5;
const int maxn = 1e5 + 5;
const int N = 200 + 5;
long long a[maxn];
long long ans, sum;
long long d[N][N];
long long dis[N][N];
vector<int> v[65];
vector<int> vec;
int getid(int x) {
  return lower_bound(vec.begin(), vec.end(), x) - vec.begin() + 1;
}
long long Folyd(int now) {
  long long mins = inf;
  for (int k = 1; k <= now; ++k) {
    for (int i = 1; i < k; ++i)
      for (int j = i + 1; j < k; ++j) {
        long long tmp = dis[i][j] + d[k][i] + d[j][k];
        if (mins > tmp) {
          mins = tmp;
          sum = 1;
        } else if (tmp == mins)
          ++sum;
      }
    for (int i = 1; i <= now; ++i)
      for (int j = 1; j <= now; ++j) {
        if (dis[i][j] > dis[i][k] + dis[k][j]) {
          dis[i][j] = dis[i][k] + dis[k][j];
        }
      }
  }
  return mins < inf ? mins : -1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 0; j <= 62; j++) {
      if (a[i] & (1LL << j)) {
        v[j].push_back(i);
      }
    }
  }
  ans = inf;
  for (int i = 0; i <= 62; i++) {
    if (v[i].size() >= 3) {
      ans = 3;
      break;
    }
  }
  if (ans < inf) {
    cout << ans << endl;
    return 0;
  }
  for (int i = 0; i <= 62; i++) {
    if (v[i].size() == 2) {
      int x = v[i][0];
      int y = v[i][1];
      vec.push_back(x);
      vec.push_back(y);
    }
  }
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  n = vec.size();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      d[i][j] = dis[i][j] = inf;
    }
    d[i][i] = dis[i][i] = 1;
  }
  for (int i = 0; i <= 62; i++) {
    if (v[i].size() == 2) {
      int x = getid(v[i][0]);
      int y = getid(v[i][1]);
      d[x][y] = d[y][x] = 1;
      dis[x][y] = dis[y][x] = 1;
    }
  }
  ans = Folyd(n);
  if (ans == inf)
    puts("-1");
  else
    cout << ans << endl;
}
