#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const long long int P = 1000000007;
set<long long int> gr[N];
long long int ans;
long long int bfs(long long int node) {
  int vis[N];
  memset(vis, 0, sizeof(vis));
  queue<tuple<long long int, long long int, long long int> > q;
  q.push({node, -1, 0});
  while (!q.empty()) {
    long long int now = get<0>(q.front());
    long long int par = get<1>(q.front());
    long long int lev = get<2>(q.front());
    q.pop();
    if (vis[now]) return vis[now] + lev;
    vis[now] = lev;
    for (auto i : gr[now]) {
      if (i == par) continue;
      q.push({i, now, lev + 1});
    }
  }
  return INT_MAX;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  ans = INT_MAX;
  for (long long int i = 0; i < 75; i++) {
    vector<long long int> v;
    for (long long int j = 0; j < n; j++) {
      if ((arr[j] >> i) % 2) v.push_back(j);
    }
    if (v.size() >= 3) {
      cout << 3, cout << "\n";
      return 0;
    }
    if (v.size() < 2)
      continue;
    else {
      gr[v[0]].insert(v[1]);
      gr[v[1]].insert(v[0]);
      ans = min(ans, bfs(v[0]));
      ans = min(ans, bfs(v[1]));
    }
  }
  if (ans == INT_MAX)
    cout << -1, cout << "\n";
  else
    cout << ans, cout << "\n";
  cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
  return 0;
}
