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>
using namespace std;
void canhazfast() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
  T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
  while (b) {
    T q = a / b;
    a %= b;
    swap(a, b);
    x0 -= q * x1;
    swap(x0, x1);
    y0 -= q * y1;
    swap(y0, y1);
  }
  x = x0;
  y = y0;
  return a;
}
int ctz(unsigned x) { return __builtin_ctz(x); }
int ctzll(unsigned long long x) { return __builtin_ctzll(x); }
int clz(unsigned x) { return __builtin_clz(x); }
int clzll(unsigned long long x) { return __builtin_clzll(x); }
int popcnt(unsigned x) { return __builtin_popcount(x); }
int popcntll(unsigned long long x) { return __builtin_popcountll(x); }
int bsr(unsigned x) { return 31 ^ clz(x); }
int bsrll(unsigned long long x) { return 63 ^ clzll(x); }
vector<int> vset;
vector<int> x[64];
bool vis[100016];
int p[100016];
int d[100016];
int q[100016];
vector<int> adj[100016];
long long a[100016];
int bfs(int s) {
  int k = 0;
  int res = 12345;
  for (int i : vset) {
    d[i] = 0;
    p[i] = 0;
    vis[i] = false;
  }
  vis[s] = true;
  q[k++] = s;
  for (int i = 0; i < k; ++i) {
    int u = q[i];
    int dv = d[u] + 1;
    for (int v : adj[u]) {
      if (v == p[u]) continue;
      if (vis[v]) {
        res = min(res, d[u] + d[v] + 1);
      } else {
        p[v] = u;
        d[v] = dv;
        vis[v] = true;
        q[k++] = v;
      }
    }
  }
  return res;
}
int main() {
  canhazfast();
  int n, ans = 12345;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    for (int j = 0; j < 60; ++j) {
      if ((a[i] >> j) & 1) x[j].push_back(i);
    }
  }
  for (int i = 0; i < 60; ++i) {
    if (x[i].size() >= 3) return cout << "3\n", 0;
    if (x[i].size() == 2) {
      int u = x[i][0], v = x[i][1];
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
  }
  for (int i = 1; i <= n; ++i) {
    sort((adj[i]).begin(), (adj[i]).end());
    adj[i].erase(unique((adj[i]).begin(), (adj[i]).end()), adj[i].end());
  }
  for (int i = 1; i <= n; ++i) {
    if (adj[i].size()) vset.push_back(i);
  }
  for (int i : vset) ans = min(ans, bfs(i));
  if (ans >= 12345) ans = -1;
  cout << ans << '\n';
  return 0;
}
