#include <bits/stdc++.h>
using namespace std;
struct node {
  long long val, cnt, parent;
  node(long long a, long long b, long long c) : val(a), cnt(b), parent(c) {}
};
vector<long long> N;
vector<vector<long long> > edges;
const long long inf = 1e18;
long long BFS(int u) {
  queue<node> q;
  q.push(node(u, 0, -1));
  while (!q.empty()) {
    node nod = q.front();
    q.pop();
    if (nod.val == u && nod.cnt > 0) return nod.cnt;
    for (int i = 0; i < (edges[nod.val].size()); i++) {
      if (edges[nod.val][i] == nod.parent) continue;
      q.push(node(edges[nod.val][i], nod.cnt + 1, nod.val));
    }
  }
  return inf;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<vector<long long> > v(64);
  for (int i = 0; i < (n); i++) {
    long long a;
    cin >> a;
    if (a) {
      long long x = log2(a);
      v[x].push_back(a);
    }
  }
  for (int i = 0; i < (64); i++) {
    if (v[i].size() > 2) {
      cout << 3 << endl;
      return 0;
    }
  }
  for (int i = 0; i < (64); i++)
    for (int j = 0; j < (v[i].size()); j++) N.push_back(v[i][j]);
  edges = vector<vector<long long> >(N.size());
  for (int i = 0; i < (N.size()); i++) {
    for (int j = i + 1; j < (N.size()); j++) {
      if (N[i] & N[j]) {
        edges[i].push_back(j);
        edges[j].push_back(i);
      }
    }
  }
  long long ans = 1e18;
  for (int i = 0; i < (N.size()); i++) {
    ans = min(BFS(i), ans);
  }
  cout << (ans == inf ? -1 : ans) << endl;
}
