#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long res = 0, f = 1;
  char c = getchar();
  while (!(c >= '0' && c <= '9') && c != '-') c = getchar();
  if (c == '-') f = -1, c = getchar();
  while ((c >= '0' && c <= '9'))
    res = (res << 3) + (res << 1) + (c ^ 48), c = getchar();
  return res * f;
}
const int maxn = 1e5 + 10;
int n, b[100], val[maxn];
long long a[maxn], c[maxn];
vector<long long> vec[100];
map<long long, int> ma;
int e[maxn][2], h[maxn], cnt;
void add_edge(int u, int v) {
  e[++cnt][0] = v;
  e[cnt][1] = h[u];
  h[u] = cnt;
  return;
}
int vis[maxn];
int ans = 99999999;
void dfs(int u, int fa, int y) {
  vis[u] = 1;
  for (int i = h[u]; i; i = e[i][1]) {
    int v = e[i][0];
    if (v == fa) continue;
    if (vis[v])
      ans = min(ans, y);
    else
      dfs(v, u, y + 1);
  }
  vis[u] = 0;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read(), c[i] = a[i];
  sort(c + 1, c + n + 1);
  int m = unique(c + 1, c + n + 1) - c - 1;
  for (int i = 1; i <= n; i++) {
    int id = lower_bound(c + 1, c + m + 1, a[i]) - c;
    val[id]++;
  }
  for (int i = 1; i <= m; i++) {
    long long x = c[i];
    for (int j = 0; j <= 62; j++)
      if (x & (1LL << j)) {
        b[j] += val[i];
        if (b[j] > 2) {
          printf("3\n");
          return 0;
        }
        vec[j].push_back(x);
      }
  }
  int tot = 0;
  for (int i = 0; i <= 62; i++)
    if (vec[i].size() == 2) {
      if (ma.count(vec[i][0]) == 0) {
        ma[vec[i][0]] = ++tot;
      }
      if (ma.count(vec[i][1]) == 0) {
        ma[vec[i][1]] = ++tot;
      }
      add_edge(ma[vec[i][0]], ma[vec[i][1]]);
      add_edge(ma[vec[i][1]], ma[vec[i][0]]);
    }
  for (int i = 1; i <= tot; i++) {
    dfs(i, 0, 1);
  }
  if (ans != 99999999)
    printf("%d\n", ans);
  else
    printf("-1\n");
  return 0;
}
