#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
vector<int> asd[100009], adj[100009];
void add(int u, int v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}
int ans = 1000000007, vis[100009];
void dfs(int nd, int pr, int lvl) {
  if (lvl >= ans) return;
  if (vis[nd]) {
    ans = lvl;
    return;
  }
  vis[nd] = 1;
  for (__typeof((adj[nd]).begin()) it = (adj[nd]).begin();
       it != (adj[nd]).end(); it++)
    if (*it != pr) dfs(*it, nd, lvl + 1);
  vis[nd] = 0;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int j = 1; j <= n; j++) {
    long long x;
    scanf("%lld", &x);
    for (int i = 59; i >= 0; i--)
      if (x >> i & 1) asd[i].push_back(j);
  }
  for (int i = 0; i < 60; i++) {
    if (asd[i].size() >= 3) {
      puts("3");
      return 0;
    }
    if (asd[i].size() == 2) add(asd[i][0], asd[i][1]);
  }
  for (int i = 1; i <= n; i++) dfs(i, -1, 0);
  if (ans == 1000000007) ans = -1;
  printf("%d\n", ans);
  return 0;
}
