#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long Hashimoto = 0;
  bool Kanna = 1;
  char I_Love = getchar();
  while (I_Love < '0' || I_Love > '9') {
    if (I_Love == '-') Kanna = 0;
    I_Love = getchar();
  }
  while (I_Love >= '0' && I_Love <= '9') {
    Hashimoto = Hashimoto * 10 + I_Love - '0';
    I_Love = getchar();
  }
  return (Kanna ? Hashimoto : -Hashimoto);
}
template <typename T1, typename T2>
inline void Umax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T1, typename T2>
inline void Umin(T1 &a, T2 b) {
  if (a > b) a = b;
}
int n;
vector<int> a[64];
int v[111111];
vector<int> g[111111];
long long ans = (1000000000);
void dfs(int x, int p, int dep) {
  v[x] = dep;
  for (int i = 0; i < (g[x].size()); ++i) {
    int to = g[x][i];
    if (to == p) continue;
    if (v[to] == 0)
      dfs(to, x, dep + 1);
    else if (v[to] < dep) {
      ans = min(ans, dep - v[to] + 1ll);
    }
  }
  v[x] = 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  n = read();
  for (int i = 0; i < (n); ++i) {
    long long x = read();
    for (int j = 0; j < (62); ++j)
      if (x & (1ll << j)) a[j].push_back(i);
  }
  for (int j = 0; j < (62); ++j) {
    if (a[j].size() >= 3) {
      cout << 3 << endl;
      return 0;
    }
    if (a[j].size() <= 1) continue;
    int x = a[j][0], y = a[j][1];
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 0; i < (n); ++i) {
    sort(g[i].begin(), g[i].end());
    g[i].erase(unique(g[i].begin(), g[i].end()), g[i].end());
  }
  for (int i = 0; i < (n); ++i)
    if (g[i].size() && !v[i]) {
      dfs(i, -1, 1);
    }
  cout << (ans == (1000000000) ? -1 : ans) << endl;
  return 0;
}
