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;
const int N = 1e6;
const long long mod = 1e9 + 7;
const long long mod2 = 998244353;
const int oo = 0x7fffffff;
const int sup = 0x80000000;
template <typename it>
void db(it *begin, it *end) {
  while (begin != end) cout << (*begin++) << " ";
  puts("");
}
template <typename it>
string to_str(it n) {
  string s = "";
  while (n) s += n % 10 + '0', n /= 10;
  reverse(s.begin(), s.end());
  return s;
}
template <typename it>
int o(it a) {
  cout << a << endl;
  return 0;
}
inline long long mul_64(long long x, long long y, long long c) {
  return (x * y - (long long)((long double)x / c * y) * c + c) % c;
}
long long ksm(long long a, long long b, long long c) {
  long long ans = 1;
  for (; b; b >>= 1, a = a * a % c)
    if (b & 1) ans = ans * a % c;
  return ans;
}
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b)
    x = 1, y = 0;
  else
    exgcd(b, a % b, y, x), y -= (a / b) * x;
}
int n;
int dp[150][150];
int dis[150][150];
vector<long long> v;
int floyd() {
  int minn = 1e6;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < k; i++) {
      for (int j = i + 1; j < k; j++) {
        minn = min(minn, dis[i][k] + dis[k][j] + dp[i][j]);
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  return minn;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    if (x == 0) continue;
    v.emplace_back(x);
  }
  n = v.size();
  if (n > 130) return o(3);
  if (n < 3) return o(-1);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) dp[i][j] = dis[i][j] = i == j ? 0 : 233;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (v[i] & v[j]) {
        dp[i][j] = dp[j][i] = dis[i][j] = dis[j][i] = 1;
      }
    }
  }
  int ans = floyd();
  if (ans >= 3 && ans <= n)
    return o(ans);
  else
    return o(-1);
}
