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;
using lli = long long int;
using vb = vector<bool>;
using vc = vector<char>;
using vd = vector<double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vlli = vector<lli>;
using vvlli = vector<vlli>;
using pi = pair<int, int>;
using plli = pair<lli, lli>;
void readc(char &q) { scanf("%c", &q); }
char readc() {
  char q;
  scanf("%c", &q);
  return q;
}
void readint(int &q) { scanf("%d", &q); }
int readint() {
  int q;
  scanf("%d", &q);
  return q;
}
void readlong(lli &q) { scanf("%lld", &q); }
lli readlong() {
  lli q;
  scanf("%lld", &q);
  return q;
}
void readdbl(double &q) { scanf("%lf", &q); }
double readdbl() {
  double q;
  scanf("%lf", &q);
  return q;
}
void printint(int q) { printf("%d", q); }
void printlong(lli q) { printf("%lld", q); }
void printdbl(double q, int p = 6) { printf("%.*lf", p, q); }
void readln() { scanf("\n"); }
void println() { printf("\n"); }
void printsp() { printf(" "); }
void print(int q) { printint(q); }
void print(long q) { printlong((lli)q); }
void print(lli q) { printlong(q); }
void print(double q) { printdbl(q); }
void print(char c) { printf("%c", c); }
void print(pi q) {
  print(q.first);
  printsp();
  print(q.second);
}
void print(vi q) {
  for (int i = 0; i < q.size(); ++i) {
    print(q[i]);
    printsp();
  }
}
void print(vlli q) {
  for (int i = 0; i < q.size(); ++i) {
    print(q[i]);
    printsp();
  }
}
void print(vd q) {
  for (int i = 0; i < q.size(); ++i) {
    print(q[i]);
    printsp();
  }
}
template <typename T>
void println(T q) {
  print(q);
  println();
}
template <typename T>
T maxim(T first, T second) {
  return (first > second) ? first : second;
}
template <typename T>
T maxim(T first, T second, T third) {
  return mndlim(maxim(first, second), third);
}
template <typename T>
T minim(T first, T second) {
  return (first < second) ? first : second;
}
template <typename T>
T minim(T first, T second, T third) {
  return minim(minim(first, second), third);
}
template <typename T>
T middle(T first, T second, T third) {
  return first + second + third - maxim(first, second, third) -
         minim(first, second, third);
}
template <typename T>
T abs(T arg) {
  return arg < 0 ? -arg : arg;
}
const lli modulo = 1000000007;
vi bits[66];
int n;
vvi g;
vb used;
int bfs(int v) {
  queue<int> q;
  q.push(v);
  used.resize(0);
  used.resize(n, false);
  vi dist(n), prev(n);
  used[v] = true;
  dist[v] = 0;
  prev[v] = -1;
  int best = 1000000;
  while (!q.empty()) {
    int w = q.front();
    q.pop();
    for (int i = 0; i < g[w].size(); ++i) {
      int next = g[w][i];
      if (prev[w] == next) continue;
      if (!used[next]) {
        used[next] = true;
        q.push(next);
        dist[next] = dist[w] + 1;
        prev[next] = w;
      } else {
        best = minim(best, dist[w] + dist[next] + 1);
      }
    }
  }
  return best;
}
int main() {
  n = readint();
  vlli a;
  for (int i = 0; i < n; ++i) {
    lli cur = readlong();
    if (cur == 0) continue;
    a.push_back(cur);
    int bit = 0;
    while (cur > 0) {
      if (cur % 2 == 1) {
        bits[bit].push_back(a.size() - 1);
      }
      bit++;
      cur /= 2ll;
    }
  }
  n = a.size();
  for (int i = 0; i < 65; ++i) {
    if (bits[i].size() > 2) {
      cout << 3 << endl;
      return 0;
    }
  }
  g.resize(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i != j && (a[i] & a[j])) {
        g[i].push_back(j);
      }
    }
  }
  int cycle = 1000000;
  for (int i = 0; i < n; ++i) {
    cycle = minim(cycle, bfs(i));
  }
  if (cycle == 1000000) cycle = -1;
  cout << cycle << endl;
  return 0;
}
