#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int b[205][205], dis[205][205];
long long a[maxn];
vector<int> v[70];
map<int, int> mp;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 64; j++) {
      if ((a[i] >> j) & 1) v[j].push_back(i);
    }
  }
  memset(b, 0x3f, sizeof(b));
  memset(dis, 0x3f, sizeof(dis));
  int tot = 0, x, y;
  for (int i = 0; i < 64; i++) {
    if (v[i].size() >= 3) {
      printf("3\n");
      return 0;
    }
    for (int j = 0; j < (int)v[i].size(); j++) {
      if (mp[v[i][j]])
        x = mp[v[i][j]];
      else
        x = ++tot, mp[v[i][j]] = x;
      for (int k = j + 1; k < (int)v[i].size(); k++) {
        if (mp[v[i][k]])
          y = mp[v[i][k]];
        else
          y = ++tot, mp[v[i][k]] = y;
        b[x][y] = 1;
        b[y][x] = 1;
        dis[x][y] = 1;
        dis[y][x] = 1;
      }
    }
  }
  int ans = 0x3f3f3f3f;
  for (int k = 1; k <= tot; k++) {
    for (int i = 1; i < k; i++) {
      for (int j = i + 1; j < k; j++) {
        if ((long long)dis[i][j] + b[i][k] + b[k][j] < ans) {
          ans = dis[i][j] + b[i][k] + b[k][j];
        }
      }
    }
    for (int i = 1; i <= tot; i++) {
      for (int j = 1; j <= tot; j++) {
        if (dis[i][j] > dis[i][k] + dis[k][j]) {
          dis[i][j] = dis[i][k] + dis[k][j];
        }
      }
    }
  }
  if (ans == 0x3f3f3f3f)
    printf("-1\n");
  else
    printf("%d\n", ans);
  return 0;
}
