#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
vector<int> G[N];
vector<int> has[67];
vector<int> pt;
int dis[N];
long long a[N];
int ans = 0x3f3f3f3f;
void dfs(int u, int fa, int s) {
  for (auto v : G[u]) {
    if (v == fa) continue;
    if (v == s) {
      ans = min(ans, dis[u] + 1);
      continue;
    }
    if (dis[v] != -1) continue;
    dis[v] = dis[u] + 1;
    dfs(v, u, s);
  }
  dis[u] = -1;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", a + i);
    for (int k = 63; k >= 0; --k) {
      long long tem = ((1ll << k) & a[i]);
      if (tem) has[k].push_back(i);
    }
  }
  for (int i = 63; i >= 0; --i) {
    if (has[i].size() >= 3) {
      puts("3");
      return 0;
    }
    if (has[i].size() == 2) {
      int u = has[i][0], v = has[i][1];
      G[u].push_back(v);
      G[v].push_back(u);
      pt.push_back(u);
      pt.push_back(v);
    }
  }
  sort(pt.begin(), pt.end());
  pt.erase(unique(pt.begin(), pt.end()), pt.end());
  for (int i = 0; i < pt.size(); ++i) {
    dis[pt[i]] = 0;
    dfs(pt[i], 0, pt[i]);
  }
  if (ans == 0x3f3f3f3f) ans = -1;
  printf("%d", ans);
  return 0;
}
