#include <bits/stdc++.h>
const int inf = 1039074182;
using namespace std;
vector<int> bit[65];
int n;
long long a[100005];
vector<int> vec[100005];
bool visit[100005];
int res;
map<long long, int> tb;
void dfs(int x, int depth, int par) {
  visit[x] = 1;
  for (auto u : vec[x]) {
    if (u == par) continue;
    if (visit[u])
      res = min(res, depth);
    else
      dfs(u, depth + 1, x);
  }
  visit[x] = 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  long long x, t;
  for (long long i = 0; i <= 60; i++) {
    tb[(1LL << i)] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> x;
    a[i] = x;
    t = x;
    while (x) {
      bit[tb[(x & -x)]].push_back(i);
      x &= (x - 1);
    }
  }
  for (int i = 0; i < 65; i++) {
    if (bit[i].size() >= 3) {
      cout << 3 << endl;
      return 0;
    } else {
      if (bit[i].size() == 2) {
        vec[bit[i][0]].push_back(bit[i][1]);
        vec[bit[i][1]].push_back(bit[i][0]);
      }
    }
  }
  res = inf;
  for (int i = 0; i < n; i++) {
    dfs(i, 1, -1);
  }
  if (res == inf) {
    cout << -1 << endl;
  } else {
    cout << res << endl;
  }
  return 0;
}
