#include <bits/stdc++.h>
using namespace std;
long long const mod = 1e9 + 7;
long long const inf = 2e18;
inline long long add(long long a, long long b) {
  return (a % mod + b % mod + mod) % mod;
}
inline long long mul(long long a, long long b) {
  return (a % mod * b % mod + mod) % mod;
}
inline long long sub(long long a, long long b) {
  return (a % mod - b % mod + mod) % mod;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long modexp(long long x, long long n) {
  if (n == 0) {
    return 1;
  } else if (n & 1) {
    return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
  } else {
    return (modexp((x * x) % mod, n / 2) % mod);
  }
}
long long modinv(long long n) { return modexp(n, mod - 2); }
long long const MAX = 200001;
long long n;
vector<long long> gr[MAX];
int shortest_cycle(int n) {
  int ans = INT_MAX;
  for (int i = 0; i < n; i++) {
    if (gr[i].size() == 0) continue;
    vector<int> dist(n, (int)(1e9));
    vector<int> par(n, -1);
    dist[i] = 0;
    queue<int> q;
    q.push(i);
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (int child : gr[x]) {
        if (dist[child] == (int)(1e9)) {
          dist[child] = 1 + dist[x];
          par[child] = x;
          q.push(child);
        } else if (par[x] != child and par[child] != x)
          ans = min(ans, dist[x] + dist[child] + 1);
      }
    }
  }
  if (ans == INT_MAX)
    return -1;
  else
    return ans;
}
void solve() {
  cin >> n;
  long long a[MAX];
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<long long> dp[64];
  for (int b = 0; b < (64); b++) {
    long long c = 0;
    vector<long long> v;
    for (int i = 0; i < (n); i++) {
      if (a[i] & (1LL << b)) {
        c++;
        v.push_back(i);
      }
    }
    if (c >= 3) {
      cout << "3\n";
      return;
    }
    if (v.size() == 2) {
      gr[v[0]].push_back(v[1]);
      gr[v[1]].push_back(v[0]);
    }
  }
  cout << shortest_cycle(n);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  for (int t = 1; t <= T; t++) {
    solve();
  }
  return 0;
}
