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;
vector<pair<long long int, long long int>> ed;
long long int n;
long long int solve(long long int u, long long int v, long long int ind) {
  vector<long long int> adj[n + 1];
  for (long long int i = 0; i < ed.size(); i++) {
    long long int x = ed[i].first;
    long long int y = ed[i].second;
    if (i == ind) continue;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int>>,
                 greater<pair<long long int, long long int>>>
      pq;
  pq.push({0, u});
  long long int dist[n + 1];
  long long int visit[n + 1];
  for (long long int i = 1; i <= n; i++) {
    dist[i] = 1e9;
    visit[i] = 0;
  }
  dist[u] = 0;
  while (!pq.empty()) {
    long long int u = pq.top().second;
    pq.pop();
    visit[u] = 1;
    for (auto it : adj[u]) {
      long long int v = it;
      if (!visit[v] && 1 + dist[u] < dist[v]) {
        dist[v] = 1 + dist[u];
        pq.push({dist[v], v});
      }
    }
  }
  return dist[v];
}
signed main() {
  cin >> n;
  long long int a[n + 1];
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  vector<long long int> bit[61], adj[n + 1];
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 0; j <= 60; j++) {
      if (a[i] & ((long long int)1 << j)) bit[j].push_back(i);
    }
  }
  map<pair<long long int, long long int>, long long int> mp;
  for (long long int i = 0; i <= 60; i++) {
    long long int s = bit[i].size();
    if (s >= 3) {
      cout << 3;
      return 0;
    }
    for (long long int j = 0; j < s; j++) {
      for (long long int k = j + 1; k < s; k++) {
        long long int u = bit[i][j];
        long long int v = bit[i][k];
        if (!mp[{u, v}] && !mp[{u, v}]) {
          ed.push_back({u, v});
          mp[{u, v}] = 1;
          mp[{v, u}] = 1;
        }
      }
    }
  }
  long long int ans = 1e9;
  for (long long int i = 0; i < ed.size(); i++) {
    long long int u = ed[i].first;
    long long int v = ed[i].second;
    long long int dis = solve(u, v, i);
    if (dis == 1e9) continue;
    ans = min(ans, 1 + dis);
  }
  if (ans == 1e9)
    cout << -1;
  else
    cout << ans;
}
