#include <bits/stdc++.h>
using namespace std;
long long n, a[100005], b[100005], dist[130][130], s[130][130], ans = LLONG_MAX,
                                                                cnt;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] != 0) b[++cnt] = a[i];
  }
  for (long long i = 1; i <= 60; i++) {
    long long cnt = 0;
    for (long long j = 1; j <= n; j++) cnt += ((a[j] >> (i - 1)) & 1);
    if (cnt >= 3) return puts("3"), 0;
  }
  for (long long i = 1; i <= cnt; i++)
    for (long long j = 1; j <= cnt; j++)
      if (i != j && (b[i] & b[j]))
        s[i][j] = 1, dist[i][j] = 1;
      else
        dist[i][j] = s[i][j] = 0x3f3f3f3f;
  for (long long k = 1; k <= cnt; k++) {
    for (long long i = 1; i < k; i++)
      for (long long j = i + 1; j < k; j++)
        ans = min(dist[i][j] + s[i][k] + s[k][j], ans);
    for (long long i = 1; i <= cnt; i++)
      for (long long j = 1; j <= cnt; j++)
        dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
  }
  cout << ((ans >= 0x3f3f3f3f) ? -1 : ans) << endl;
}
