You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).

Find the length of the shortest cycle in this graph or determine that it doesn't have cycles at all.

Input

The first line contains one integer n (1 ≤ n ≤ 10^5) — number of numbers.

The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^{18}).

Output

If the graph doesn't have any cycles, output -1. Else output the length of the shortest cycle.

Examples

Input


4
3 6 28 9


Output


4

Input


5
5 12 9 16 48


Output


3

Input


4
1 2 4 8


Output


-1

Note

In the first example, the shortest cycle is (9, 3, 6, 28).

In the second example, the shortest cycle is (5, 12, 9).

The graph has no cycles in the third example.
#include <bits/stdc++.h>
const int maxn = 1e5 + 9, mod = 998244353, inf = 0x3f3f3f3f;
int Read() {
  int x(0), f(1);
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3ll) + (x << 1ll) + c - '0';
    c = getchar();
  }
  return x * f;
}
void Chkmin(int &x, int y) {
  if (y < x) x = y;
}
void Chkmax(int &x, int y) {
  if (y > x) x = y;
}
int add(int x, int y) { return x += y, x >= mod ? x - mod : x; }
int dec(int x, int y) { return x -= y, x < 0 ? x + mod : x; }
int mul(int x, int y) { return 1ll * x * y % mod; }
int Pow(int base, int b) {
  int ret(1);
  while (b) {
    if (b & 1) ret = mul(ret, base);
    base = mul(base, base);
    b >>= 1;
  }
  return ret;
}
int n, Ans(inf);
long long a[maxn];
int vis[maxn];
std::vector<std::pair<int, int> > V[200];
void Bfs(int s) {
  static int lu[maxn], pre[maxn], mark[maxn];
  for (int i = 1; i <= n; ++i) mark[i] = pre[i] = 0;
  lu[s] = 1;
  std::queue<int> que;
  que.push(s);
  while (que.size()) {
    int u(que.front());
    que.pop();
    if (lu[u] > Ans) return;
    for (int i = 0; i < V[u].size(); ++i) {
      int v(V[u][i].first);
      if (mark[v] || vis[V[u][i].second]) continue;
      mark[v] = 1;
      lu[v] = lu[u] + 1;
      if (v == s) {
        Chkmin(Ans, lu[u]);
        return;
      } else {
        pre[v] = u;
        que.push(v);
      }
    }
  }
}
void Get(int s) {
  int limit(1), len(0);
  while (limit < n) {
    limit <<= 1;
    ++len;
  }
  for (int i = 0; i <= len; ++i) {
    for (int j = 0; j < V[s].size(); ++j) {
      int v(V[s][j].first), id(V[s][j].second);
      if ((v >> i) & 1) {
        vis[id ^ 1] = 1;
      } else {
        vis[id] = 1;
      }
    }
    Bfs(s);
    for (int j = 0; j < V[s].size(); ++j) {
      int id(V[s][j].second);
      vis[id] = vis[id ^ 1] = 0;
    }
  }
}
void Solve() {
  std::vector<int> S[100];
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= 60; ++j)
      if ((a[i] >> (1ll * j)) & 1) {
        S[j].push_back(i);
      }
  }
  for (int j = 0; j <= 60; ++j)
    if (S[j].size() >= 3) {
      puts("3");
      exit(0);
    }
  assert(n <= 61 * 2);
  int tot(0);
  for (int j = 1; j <= n; ++j) {
    for (int k = j + 1; k <= n; ++k)
      if (a[j] & a[k]) {
        V[j].push_back(std::pair<int, int>(k, tot));
        tot++;
        V[k].push_back(std::pair<int, int>(j, tot));
        tot++;
      }
  }
  for (int i = 1; i <= n; ++i) {
    Get(i);
  }
  if (Ans == inf) {
    puts("-1");
    return;
  }
  printf("%d\n", Ans);
  return;
}
long long b[maxn];
int main() {
  n = Read();
  int m(0);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", a + i);
    if (a[i]) {
      b[++m] = a[i];
    }
  }
  n = m;
  for (int i = 1; i <= m; ++i) {
    a[i] = b[i];
  }
  Solve();
  return 0;
}
