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;
ifstream in;
ofstream out;
const long long kk = 1000;
const long long ml = kk * kk;
const long long mod = ml * kk + 7;
const long long inf = ml * ml * ml + 7;
long long n, i, j, v, e;
vector<long long> m, col;
vector<bool> ver;
vector<vector<long long>> reb;
bool viv = false;
void ans(long long res) {
  cout << res << endl;
  exit(0);
}
void build() {
  vector<vector<long long>> kol(64);
  for (long long i = 0; i < n; i++) {
    long long j = 0;
    long long x = m[i];
    while (x) {
      if (x & 1) kol[j].push_back(i);
      x >>= 1;
      j++;
    }
  }
  for (auto i : kol)
    if (i.size() >= 3) ans(3);
  ver.resize(n);
  reb.resize(n);
  for (auto i : kol)
    if (i.size() > 1) {
      reb[i[0]].push_back(i[1]);
      reb[i[1]].push_back(i[0]);
      e++;
      ver[i[0]] = 1;
      ver[i[1]] = 1;
    }
}
long long from(long long v) {
  vector<long long> lev(n, -1);
  vector<long long> by(n, -1);
  deque<long long> st;
  st.push_back(v);
  lev[v] = 0;
  while (st.size()) {
    long long cur = st.front();
    st.pop_front();
    for (auto sos : reb[cur]) {
      if (lev[sos] == -1) {
        st.push_back(sos);
        if (viv) cout << "In " << v << " add " << sos << endl;
        lev[sos] = lev[cur] + 1;
        by[sos] = cur;
      }
    }
  }
  long long sh = ml;
  for (long long i = 0; i < n; i++) {
    for (auto sos : reb[i])
      if (lev[i] != -1 && lev[sos] != -1 && by[i] != sos && by[sos] != i) {
        long long len = lev[i] + lev[sos];
        len++;
        if (len > 2) sh = min(sh, len);
      }
  }
  return sh;
}
void show() {
  if (!viv) return;
  cout << "BFS: ";
  for (long long i = 0; i < n; i++) cout << from(i) << ' ';
  cout << endl;
  for (long long i = 0; i < n; i++) {
    cout << i << ": ";
    for (auto sos : reb[i]) cout << sos << ' ';
    cout << endl;
  }
}
void check() {
  v = 0;
  for (auto i : ver) v += i;
  long long sh = kk;
  for (long long i = 0; i < n; i++)
    if (ver[i]) sh = min(sh, from(i));
  if (sh >= kk) ans(-1);
  show();
  ans(sh);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 0; i < n; i++) {
    long long a;
    cin >> a;
    m.push_back(a);
  }
  build();
  check();
  return 0;
}
