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 long long N = 100010;
const long long P = 998244353;
const long long INF = 0x3f3f3f3f;
namespace fast_IO {
const long long IN_LEN = 10000000, OUT_LEN = 10000000;
char ibuf[IN_LEN], obuf[OUT_LEN], *ih = ibuf + IN_LEN, *oh = obuf,
                                  *lastin = ibuf + IN_LEN,
                                  *lastout = obuf + OUT_LEN - 1;
inline char getchar_() {
  return (ih == lastin) &&
                 (lastin = (ih = ibuf) + fread(ibuf, 1, IN_LEN, stdin),
                  ih == lastin)
             ? EOF
             : *ih++;
}
inline void putchar_(const char x) {
  if (oh == lastout) fwrite(obuf, 1, oh - obuf, stdout), oh = obuf;
  *oh++ = x;
}
inline void flush() { fwrite(obuf, 1, oh - obuf, stdout); }
inline long long read() {
  long long x(0), w(1);
  char c = getchar_();
  while (c ^ '-' && (c < '0' || c > '9')) c = getchar_();
  if (c == '-') w = -1, c = getchar_();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + c - '0', c = getchar_();
  return x * w;
}
void write(long long x) {
  if (x < 0) putchar_('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar_(x % 10 + '0');
}
inline void writes(long long x) { write(x), putchar_(' '); }
inline void writeln(long long x) { write(x), putchar_('\n'); }
}  // namespace fast_IO
using namespace fast_IO;
long long n, ans, flg, a[N], b[70], d[N];
long long head[N], nxt[N], to[N], cnte;
vector<long long> c;
queue<long long> q;
inline void add(long long u, long long v) {
  to[++cnte] = v;
  nxt[cnte] = head[u];
  head[u] = cnte;
}
inline long long dis(long long A, long long B) {
  memset(d, -1, sizeof(d));
  q.push(A);
  d[A] = 0;
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    for (long long i = head[u]; i; i = nxt[i]) {
      if (d[to[i]] == -1) {
        d[to[i]] = d[u] + 1;
        q.push(to[i]);
      }
    }
  }
  return (d[B] == -1) ? INF : d[B];
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; ++i) {
    a[i] = read();
    for (long long j = 0; j <= 60; ++j) {
      if (a[i] & (1ll << j)) {
        ++b[j];
      }
    }
  }
  for (long long i = 0; i <= 60; ++i) {
    if (b[i] > 2) {
      writeln(3);
      flush();
      return 0;
    }
  }
  ans = INF;
  for (long long j = 0; j <= 60; ++j) {
    c.clear();
    for (long long i = 1; i <= n; ++i) {
      if (a[i] & (1ll << j)) {
        c.push_back(i);
      }
    }
    if (c.size() == 2) {
      long long d = dis(c[0], c[1]);
      if (d > 1) {
        ans = min(ans, d + 1);
      }
      add(c[0], c[1]);
      add(c[1], c[0]);
    }
  }
  if (ans >= INF) {
    writeln(-1);
  } else
    writeln(ans);
  flush();
  return 0;
}
