#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long N = 1e5 + 5;
long long n, a[N];
vector<long long> adj[N];
long long shortest_cycle() {
  long long ans = INF;
  vector<long long> d(n, INF), p(n, -1);
  set<long long> s;
  for (long long i = 0; i < n; i++) {
    for (long long it : s) {
      d[it] = INF;
      p[it] = -1;
    }
    s.clear();
    queue<long long> q;
    s.insert(i);
    d[i] = 0;
    q.push(i);
    while (!q.empty()) {
      long long at = q.front();
      q.pop();
      for (long long to : adj[at]) {
        if (d[to] == INF) {
          d[to] = d[at] + 1;
          p[to] = at;
          q.push(to);
          s.insert(to);
        } else if (p[at] != to and p[to] != at) {
          ans = min(ans, d[at] + d[to] + 1);
        }
      }
    }
  }
  return (ans == INF ? -1 : ans);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> v;
  for (long long i = 0; i <= 60; i++) {
    v.clear();
    for (long long j = 0; j < n; j++) {
      if ((a[j] >> i) & 1) {
        v.push_back(j);
      }
    }
    if ((long long)(v.size()) >= 3) {
      cout << "3\n";
      return 0;
    } else {
      for (long long j = 1; j < (long long)(v.size()); j++) {
        adj[v[j]].push_back(v[j - 1]);
        adj[v[j - 1]].push_back(v[j]);
      }
    }
  }
  long long ans = shortest_cycle();
  cout << ans << endl;
  return 0;
}
