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;
pair<long long, long long> add_pair(pair<long long, long long> a,
                                    pair<long long, long long> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
long long power(long long a, long long b) {
  long long res = 1;
  a = a % ((long long)1e9 + 7);
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % ((long long)1e9 + 7);
      b--;
    }
    a = (a * a) % ((long long)1e9 + 7);
    b >>= 1;
  }
  return res;
}
long long fermat_inv(long long y) { return power(y, ((long long)1e9 + 7) - 2); }
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
long long mul(long long a, long long b) {
  return (a * (b % ((long long)1e9 + 7))) % ((long long)1e9 + 7);
}
long long sub(long long a, long long b) {
  return ((a - b) % ((long long)1e9 + 7) + ((long long)1e9 + 7)) %
         ((long long)1e9 + 7);
}
long long add(long long a, long long b) {
  return ((a + b) % ((long long)1e9 + 7) + ((long long)1e9 + 7)) %
         ((long long)1e9 + 7);
}
vector<vector<int> > G;
int n, ans;
void bfs(int rt) {
  int x;
  queue<int> q;
  vector<int> d(n), par(n);
  vector<bool> vis(n, false);
  d[rt] = 0;
  par[rt] = rt;
  q.push(rt);
  while (!q.empty()) {
    x = q.front();
    vis[x] = true;
    q.pop();
    for (auto it = (G[x]).begin(); it != (G[x]).end(); it++) {
      if (!vis[*it]) {
        d[*it] = d[x] + 1;
        par[*it] = x;
        vis[*it] = true;
        q.push(*it);
      } else {
        if (*it != par[x] && par[*it] != x) {
          ans = min(ans, d[x] + d[*it] + 1);
          if (ans == 3) return;
        }
      }
    }
  }
}
void solve() {
  int i, j;
  long long x;
  cin >> n;
  vector<long long> a;
  vector<int> cnt(61, 0ll);
  for (i = (0); i < (n); i += (1)) {
    cin >> x;
    if (x == 0) continue;
    a.push_back(x);
    for (j = 0; j < 61; j++) {
      if (x & (1ll << j)) {
        cnt[j]++;
      }
    }
  }
  for (i = (0); i < (61); i += (1)) {
    if (cnt[i] > 2) {
      cout << 3 << '\n';
      return;
    }
  }
  n = (a).size();
  G = vector<vector<int> >(n, vector<int>());
  ans = n + 1;
  for (i = (0); i < (n); i += (1)) {
    for (j = (0); j < (i); j += (1)) {
      if (a[i] & a[j]) {
        G[i].push_back(j);
        G[j].push_back(i);
      }
    }
  }
  for (i = (0); i < (n); i += (1)) {
    bfs(i);
    if (ans == 3) break;
  }
  if (ans == n + 1)
    cout << -1 << '\n';
  else
    cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
