#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long readll() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = 1e5 + 5, INF = 0x3f3f3f3f;
int n, vis[MAXN], dep[MAXN], ans;
unsigned long long a[MAXN];
vector<pair<int, int> > ed;
int g[200][200], f[200][200];
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) a[i] = readll();
  for (int i = 0; i <= 63; ++i) {
    vector<int> v;
    for (int j = 1; j <= n; ++j)
      if (a[j] & (1ULL << i)) v.push_back(j);
    if ((int)v.size() >= 3)
      return puts("3"), 0;
    else if ((int)v.size() == 2)
      ed.push_back(make_pair(v[0], v[1]));
  }
  vector<int> nd;
  for (int i = 0; i < (int)ed.size(); ++i)
    nd.push_back(ed[i].first), nd.push_back(ed[i].second);
  sort(nd.begin(), nd.end());
  nd.erase(unique(nd.begin(), nd.end()), nd.end());
  memset(g, 0x3f, sizeof(g));
  for (int i = 0; i < (int)ed.size(); ++i) {
    ed[i].first =
        lower_bound(nd.begin(), nd.end(), ed[i].first) - nd.begin() + 1;
    ed[i].second =
        lower_bound(nd.begin(), nd.end(), ed[i].second) - nd.begin() + 1;
    g[ed[i].first][ed[i].second] = g[ed[i].second][ed[i].first] = 1;
  }
  n = nd.size();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) f[i][j] = g[i][j];
  for (int i = 1; i <= n; ++i) f[i][i] = 0;
  ans = INF;
  for (int k = 1; k <= n; ++k) {
    for (int i = 1; i < k; ++i) {
      if (g[i][k] == INF) continue;
      for (int j = i + 1; j < k; ++j) {
        if (g[k][j] == INF || f[i][j] == INF) continue;
        ans = min(ans, g[i][k] + g[k][j] + f[i][j]);
      }
    }
    for (int i = 1; i <= n; ++i) {
      if (i == k || f[i][k] == INF) continue;
      for (int j = 1; j <= n; ++j) {
        if (j == i || j == k || f[k][j] == INF) continue;
        f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
      }
    }
  }
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}
