#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 1;
const long long INF = 0x3f3f3f3fLL;
long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
struct Edge {
  long long to, next;
} e[129];
long long cnt, head[MAXN], vis[MAXN], dfn[MAXN], tot, ans = INF;
long long a[MAXN], w[MAXN][129], sum[MAXN], n;
void add(long long x, long long y) {
  e[++cnt].to = y;
  e[cnt].next = head[x];
  head[x] = cnt;
}
void dfs(long long x, long long fa) {
  vis[x] = 1;
  dfn[x] = ++tot;
  for (long long i = head[x]; i; i = e[i].next) {
    long long y = e[i].to;
    if (y != fa) {
      if (dfn[y]) {
        ans = min(ans, dfn[x] - dfn[y] + 1);
      } else
        dfs(y, x);
    }
  }
  dfn[x] = 0;
  tot--;
}
signed main() {
  n = read();
  if (n <= 2) {
    cout << -1;
    return 0;
  }
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 0; i <= 63; i++) {
    for (long long j = 1; j <= n; j++) {
      if ((a[j] >> i) & 1LL) {
        w[j][i] = 1;
        sum[i]++;
      }
      if (sum[i] == 3) {
        cout << 3 << endl;
        return 0;
      }
    }
    if (sum[i] == 2) {
      long long b = 0, c = 0;
      for (long long j = 1; j <= n; j++) {
        if (w[j][i]) {
          b = j;
          break;
        }
      }
      for (long long j = b + 1; j <= n; j++) {
        if (w[j][i]) {
          c = j;
          break;
        }
      }
      add(b, c);
      add(c, b);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) dfs(i, 0);
  }
  if (ans != INF) {
    cout << ans << endl;
  } else {
    cout << -1;
  }
  return 0;
}
