You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).

Find the length of the shortest cycle in this graph or determine that it doesn't have cycles at all.

Input

The first line contains one integer n (1 ≤ n ≤ 10^5) — number of numbers.

The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^{18}).

Output

If the graph doesn't have any cycles, output -1. Else output the length of the shortest cycle.

Examples

Input


4
3 6 28 9


Output


4

Input


5
5 12 9 16 48


Output


3

Input


4
1 2 4 8


Output


-1

Note

In the first example, the shortest cycle is (9, 3, 6, 28).

In the second example, the shortest cycle is (5, 12, 9).

The graph has no cycles in the third example.
import java.io.*;
import java.util.*;
import java.util.stream.*;

import static java.lang.Integer.*;
import static java.lang.Long.*;

public class m implements Runnable {
  private static final boolean ONLINE_JUDGE = true; //System.getProperty("ONLINE_JUDGE") != null;

  public static void main(String[] args) {
    new Thread(new m()).run();
  }

  @Override
  public void run() {
    try (BufferedReader reader = ONLINE_JUDGE ? new BufferedReader(new InputStreamReader(System.in))
                                              : new BufferedReader(new FileReader("input"));
         Writer writer = ONLINE_JUDGE ? new OutputStreamWriter(System.out) : new FileWriter("output");
         PrintWriter printWriter = new PrintWriter(writer);) {
      Solver solver = new Solver(reader, printWriter);
      while (solver.solve());
    } catch (IOException e) {
      e.printStackTrace(System.err);
    }
  }

  static final class Solver {
    final BufferedReader in;
    final PrintWriter out;

    public Solver(BufferedReader reader, PrintWriter writer) {
      in = reader;
      out = writer;
    }

    long gcd(long n, long m) {
      if (n == 0) return m;
      return n >= m ? gcd(n % m, m) : gcd(m % n, n);
    }

    boolean solve() throws IOException {
      String line = in.readLine();
      if (line == null) {
        return false;
      }
      if (line.isEmpty()) {
        return true;
      }
      StringTokenizer tok = new StringTokenizer(line);
      int n = parseInt(tok.nextToken());
      long a[] = new long[n];
      tok = new StringTokenizer(in.readLine());
      for (int i =0 ; i < n; ++i) {
        a[i] = parseLong(tok.nextToken());
      }
      List[] g = new List[n];
      for (int i =0 ;i < n; ++i) g[i] = new ArrayList<Integer>();
      for (int s = 0; s < 63; ++s) {
        long m = 1L << s;
        List<Integer> found = new ArrayList<>();

        for (int i = 0; i < n; ++i) {
          long res = m & a[i];
          if (res == m) {
            found.add(i);
            if (found.size() >= 3) {
              out.println(3);
              return true;
            }
          }
        }
        assert found.size() < 3;
        if (found.size() == 2) {
          debug("EDGE " + found.get(0) + " " + found.get(1));
          if (g[found.get(0)].contains(found.get(1))) continue;
          g[found.get(0)].add(found.get(1));
          g[found.get(1)].add(found.get(0));
        }
      }

      int minCycle = -1;
      for (int start = 0; start < n; ++start) {
        if (g[start].isEmpty()) continue;
        Deque<Integer> queue = new ArrayDeque<>();
        Deque<Integer> len = new ArrayDeque<>();
        queue.add(start);
        len.add(0);
        boolean[] was = new boolean[n];
        int[] dist = new int[n];
        int cycleForStart = 100;
MAIN:   while (!queue.isEmpty()) {
          Integer top = queue.poll();
          debug("top " + top);
          Integer curLen = len.poll();
          if (was[top]) {
            assert dist[top] > 0;
            cycleForStart = Math.min(cycleForStart, curLen + dist[top]);
            continue;
          }
          dist[top] = curLen;
          was[top] = true;
          for (Object next0 : g[top]) {
            Integer next = (Integer) next0;
            debug("next " + next);
            if (!was[next]) {
              debug("putting to the queue " + next + " " + curLen);
              queue.add(next);
              len.add(curLen + 1);
            }
          }
        }
        if (cycleForStart == 100) continue;
        if (minCycle < 0) minCycle = cycleForStart;
        else if (cycleForStart > 0) {
          minCycle = Math.min(minCycle, cycleForStart);
        }
      }
      out.println(minCycle);
      return true;
    }
  }

  static void debug(String s) {
    //System.out.println(s);
  }
}
