#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getrnd(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }
template <typename T1, typename T2>
bool relax(T1& a, const T2& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
bool strain(T1& a, const T2& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 1e5 + 3;
int d[N];
set<int> graph[N];
void bfs(int st) {
  for (int i = 0; i < N; ++i) d[i] = N + 1;
  d[st] = 0;
  queue<int> scope;
  scope.emplace(st);
  while (!scope.empty()) {
    int v = scope.front();
    scope.pop();
    for (int to : graph[v]) {
      if (relax(d[to], d[v] + 1)) scope.emplace(to);
    }
  }
}
void solve() {
  int n;
  cin >> n;
  vector<vector<int>> cnt(64);
  for (int i = 0; i < n; ++i) {
    ll x;
    cin >> x;
    for (int j = 0; j < 64; ++j) {
      if ((x >> j) & 1) cnt[j].emplace_back(i);
    }
  }
  for (int i = 0; i < 64; ++i) {
    if (cnt[i].size() >= 3) {
      cout << "3\n";
      return;
    }
  }
  for (int i = 0; i < 64; ++i) {
    if (cnt[i].size() < 2) continue;
    int x = cnt[i][0], y = cnt[i][1];
    graph[x].insert(y);
    graph[y].insert(x);
  }
  int res = N + 1;
  for (int i = 0; i < 64; ++i) {
    if (cnt[i].size() < 2) continue;
    int x = cnt[i][0], y = cnt[i][1];
    graph[x].erase(y);
    graph[y].erase(x);
    bfs(x);
    relax(res, d[y]);
  }
  if (res >= N)
    cout << "-1\n";
  else
    cout << res + 1 << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  srand(time(0));
  int t = 1;
  while (t--) solve();
  return 0;
}
