#include <bits/stdc++.h>
using namespace std;
long long const mod = 1e9 + 7;
long long const inf = 2e18;
inline long long add(long long a, long long b) {
  return (a % mod + b % mod + mod) % mod;
}
inline long long mul(long long a, long long b) {
  return (a % mod * b % mod + mod) % mod;
}
inline long long sub(long long a, long long b) {
  return (a % mod - b % mod + mod) % mod;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long modexp(long long x, long long n) {
  if (n == 0) {
    return 1;
  } else if (n & 1) {
    return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
  } else {
    return (modexp((x * x) % mod, n / 2) % mod);
  }
}
long long modinv(long long n) { return modexp(n, mod - 2); }
long long const MAX = 200001;
long long n;
vector<long long> gr[MAX];
int shortest_cycle(int n) {
  int ans = INT_MAX;
  for (int i = 0; i < n; i++) {
    if (gr[i].size() == 0) continue;
    vector<int> dist(n, (int)(1e9));
    vector<int> par(n, -1);
    dist[i] = 0;
    queue<int> q;
    q.push(i);
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (int child : gr[x]) {
        if (dist[child] == (int)(1e9)) {
          dist[child] = 1 + dist[x];
          par[child] = x;
          q.push(child);
        } else if (par[x] != child and par[child] != x)
          ans = min(ans, dist[x] + dist[child] + 1);
      }
    }
  }
  if (ans == INT_MAX)
    return -1;
  else
    return ans;
}
void solve() {
  cin >> n;
  long long a[MAX];
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<long long> dp[64];
  for (int b = 0; b < (64); b++) {
    long long c = 0;
    vector<long long> v;
    for (int i = 0; i < (n); i++) {
      if (a[i] & (1LL << b)) {
        c++;
        v.push_back(i);
      }
    }
    if (c >= 3) {
      cout << "3\n";
      return;
    }
    if (v.size() == 2) {
      gr[v[0]].push_back(v[1]);
      gr[v[1]].push_back(v[0]);
    }
  }
  cout << shortest_cycle(n);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  for (int t = 1; t <= T; t++) {
    solve();
  }
  return 0;
}

### Prompt

Create a solution in Cpp for the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long const mod = 1e9 + 7;
long long const inf = 2e18;
inline long long add(long long a, long long b) {
  return (a % mod + b % mod + mod) % mod;
}
inline long long mul(long long a, long long b) {
  return (a % mod * b % mod + mod) % mod;
}
inline long long sub(long long a, long long b) {
  return (a % mod - b % mod + mod) % mod;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long modexp(long long x, long long n) {
  if (n == 0) {
    return 1;
  } else if (n & 1) {
    return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
  } else {
    return (modexp((x * x) % mod, n / 2) % mod);
  }
}
long long modinv(long long n) { return modexp(n, mod - 2); }
long long const MAX = 200001;
long long n;
vector<long long> gr[MAX];
int shortest_cycle(int n) {
  int ans = INT_MAX;
  for (int i = 0; i < n; i++) {
    if (gr[i].size() == 0) continue;
    vector<int> dist(n, (int)(1e9));
    vector<int> par(n, -1);
    dist[i] = 0;
    queue<int> q;
    q.push(i);
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (int child : gr[x]) {
        if (dist[child] == (int)(1e9)) {
          dist[child] = 1 + dist[x];
          par[child] = x;
          q.push(child);
        } else if (par[x] != child and par[child] != x)
          ans = min(ans, dist[x] + dist[child] + 1);
      }
    }
  }
  if (ans == INT_MAX)
    return -1;
  else
    return ans;
}
void solve() {
  cin >> n;
  long long a[MAX];
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<long long> dp[64];
  for (int b = 0; b < (64); b++) {
    long long c = 0;
    vector<long long> v;
    for (int i = 0; i < (n); i++) {
      if (a[i] & (1LL << b)) {
        c++;
        v.push_back(i);
      }
    }
    if (c >= 3) {
      cout << "3\n";
      return;
    }
    if (v.size() == 2) {
      gr[v[0]].push_back(v[1]);
      gr[v[1]].push_back(v[0]);
    }
  }
  cout << shortest_cycle(n);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  for (int t = 1; t <= T; t++) {
    solve();
  }
  return 0;
}

```