#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > edges;
vector<bool> vis;
map<int, int> m;
int cycle = 2e9;
map<pair<int, int>, int> temp, temp1;
int bfs(int u) {
  queue<pair<pair<int, int>, int> > q;
  q.push({{u, 0}, -1});
  int f = 0;
  while (!q.empty()) {
    pair<pair<int, int>, int> p = q.front();
    q.pop();
    int a = p.first.first, d = p.first.second, par = p.second;
    for (int i = 0; i < edges[a].size(); i++) {
      int ver = edges[a][i];
      if (par == ver) continue;
      if (ver == u) return d + 1;
      q.push({{ver, d + 1}, a});
    }
  }
  return 2e9;
}
int main() {
  int n;
  cin >> n;
  vector<long long int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  edges.resize(n);
  vis.resize(n, false);
  int f = 0;
  for (int i = 0; i < 60 and f == 0; i++) {
    vector<int> o;
    for (int j = 0; j < n; j++) {
      if (v[j] % 2 == 1) o.push_back(j);
      v[j] /= 2;
    }
    if (o.size() > 2) f = 1;
    if (o.size() == 2) {
      int a = o[0], b = o[1];
      if (temp1.find({min(a, b), max(a, b)}) != temp1.end()) continue;
      edges[a].push_back(b);
      edges[b].push_back(a);
      temp1[{min(a, b), max(a, b)}] = 1;
    }
  }
  if (f == 1)
    cout << "3" << endl;
  else {
    for (int i = 0; i < n; i++) {
      int a = bfs(i);
      if (a == 1) continue;
      cycle = min(cycle, a);
    }
    if (cycle == 2e9)
      cout << "-1" << endl;
    else
      cout << cycle << endl;
  }
}
