#include <bits/stdc++.h>
using namespace std;
long long ans = 1e10;
void dfs(int node, int prev, vector<long long>& visited,
         vector<long long>& dist, vector<long long>& instack,
         vector<vector<long long>>& adj) {
  for (int i = 0; i < adj[node].size(); i++) {
    int nxt = adj[node][i];
    if (nxt != prev) {
      if (!visited[nxt]) {
        if (instack[nxt]) {
          ans = min(ans, dist[node] - dist[nxt] + 1);
        } else {
          instack[nxt] = 1;
          dist[nxt] = 1 + dist[node];
          dfs(nxt, node, visited, dist, instack, adj);
          instack[nxt] = 0;
        }
      } else {
        if (dist[nxt] > 1 + dist[node]) {
          if (instack[nxt]) {
            ans = min(ans, dist[node] - dist[nxt] + 1);
          } else {
            instack[nxt] = 1;
            dist[nxt] = 1 + dist[node];
            dfs(nxt, node, visited, dist, instack, adj);
            instack[nxt] = 0;
          }
        }
      }
    }
  }
  visited[node] = 1;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> arr(n);
  vector<vector<long long>> adj(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long fact = 1;
  long long st = 0;
  for (int i = 0; i < 61; i++) {
    int cnt = 0;
    vector<long long> temp;
    for (int j = 0; j < n; j++) {
      if (arr[j] & fact) {
        cnt++;
        temp.push_back(j);
      }
      if (cnt >= 3) {
        cout << 3 << "\n";
        return 0;
      }
    }
    for (int j = 0; j < temp.size(); j++) {
      for (int k = j + 1; k < temp.size(); k++) {
        adj[temp[j]].push_back(temp[k]);
        adj[temp[k]].push_back(temp[j]);
        st = temp[k];
      }
    }
    fact *= 2;
  }
  vector<long long> visited(n, 0), dist(n, 0), instack(n, 0);
  for (int i = 0; i < n; i++) {
    if (!visited[i]) {
      visited[i] = 0;
      dist[i] = 0;
      instack[i] = 1;
      dfs(i, -1, visited, dist, instack, adj);
    }
  }
  if (ans == 1e10) {
    cout << -1 << "\n";
  } else {
    cout << ans << "\n";
  }
}
