#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
long long a[maxn];
long long bit[100];
vector<int> ve[100];
int mp[500][500];
const int N = 500;
int m, n;
int min_loop;
int num;
int dist[N][N], pre[N][N];
int path[N];
void dfs(int i, int j) {
  int k = pre[i][j];
  if (k == 0) {
    path[num++] = j;
    return;
  }
  dfs(i, k);
  dfs(k, j);
}
void Floyd() {
  min_loop = 0x7ffffff;
  memset(pre, 0, sizeof(pre));
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i < k; i++) {
      for (int j = i + 1; j < k; j++) {
        if (dist[i][j] + mp[i][k] + mp[k][j] < min_loop) {
          min_loop = dist[i][j] + mp[i][k] + mp[k][j];
          num = 0;
          path[num++] = i;
          dfs(i, j);
          path[num++] = k;
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (dist[i][k] + dist[k][j] < dist[i][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
          pre[i][j] = k;
        }
      }
    }
  }
}
void init() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      mp[i][j] = 0x7ffffff;
      dist[i][j] = 0x7ffffff;
    }
    mp[i][i] = dist[i][i] = 0;
  }
}
int main() {
  for (int i = 0; i < 63; i++) {
    bit[i] = 1ll << (i * 1ll);
  }
  scanf("%d", &n);
  int ccc = 1;
  for (int i = 1; i <= n; i++) {
    long long xx;
    scanf("%lld", &xx);
    if (xx != 0) a[ccc++] = xx;
  }
  n = ccc - 1;
  for (int i = 1; i <= n; i++) {
    long long tem = a[i];
    for (int j = 0; j < 63; j++) {
      if ((tem & bit[j]) == bit[j]) {
        ve[j].push_back(i);
      }
    }
  }
  if (n > 128) {
    puts("3");
    return 0;
  }
  for (int i = 0; i < 63; i++) {
    if (ve[i].size() >= 3) {
      puts("3");
      return 0;
    }
  }
  init();
  for (int i = 0; i < 63; i++) {
    int len = ve[i].size();
    for (int j = 0; j < len; j++) {
      for (int k = 0; k < len; k++) {
        if (k == j) continue;
        mp[ve[i][j]][ve[i][k]] = 1;
        dist[ve[i][j]][ve[i][k]] = 1;
      }
    }
  }
  Floyd();
  if (min_loop < 0x7ffffff)
    printf("%d\n", min_loop);
  else {
    printf("-1\n");
  }
}
