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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] bitCnt = new int[63];
            TreeSet<Long> aSet = new TreeSet<>();
            for (int i = 0; i < n; i++) {
                long a = in.nextLong();
                aSet.add(a);
                for (int j = 0; j < 63; j++) {
                    if ((a & (1L << j)) > 0) {
                        bitCnt[j]++;
                    }
                }
            }
            for (int j = 0; j < 63; j++) {
                if (bitCnt[j] >= 3) {
                    out.println(3);
                    return;
                }
            }
            long[] a = new long[aSet.size()];
            int ind = 0;
            for (long cur : aSet) {
                a[ind] = cur;
                ind++;
            }
            ArrayList<ArrayList<Integer>> childs = new ArrayList<>();
            for (int i = 0; i < a.length; i++) {
                childs.add(new ArrayList<>());
                for (int j = 0; j < a.length; j++) {
                    if (i == j) continue;
                    if ((a[i] & a[j]) > 0) {
                        childs.get(i).add(j);
                    }
                }
            }
            int minPath = Integer.MAX_VALUE;
            ArrayDeque<Integer> node = new ArrayDeque<>();
            ArrayDeque<Integer> parent = new ArrayDeque<>();
            int[] path = new int[a.length];
            for (int i = 0; i < a.length; i++) {
                for (int j = 0; j < a.length; j++) {
                    path[j] = -1;
                }
                node.clear();
                parent.clear();
                node.addLast(i);
                parent.addLast(i);
                while (!node.isEmpty()) {
                    int curNode = node.removeFirst();
                    int curParent = parent.removeFirst();
                    if (path[curNode] == -1) {
                        path[curNode] = path[curParent] + 1;
                        for (int child : childs.get(curNode)) {
                            if (child != curParent) {
                                node.addLast(child);
                                parent.addLast(curNode);
                            }
                        }
                    } else {
                        minPath = Math.min(minPath, path[curNode] + path[curParent] + 1);
                    }
                }
            }
            if (minPath == Integer.MAX_VALUE) {
                out.println(-1);
            } else {
                out.println(minPath);
            }
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {

            reader = new BufferedReader(new InputStreamReader(stream));

        }

        public String nextLine() {

            try {

                return reader.readLine();

            } catch (IOException e) {

                return null;

            }

        }

        public String next() {

            while (stt == null || !stt.hasMoreTokens()) {

                stt = new StringTokenizer(nextLine());

            }

            return stt.nextToken();

        }

        public int nextInt() {

            return Integer.parseInt(next());

        }

        public long nextLong() {

            return Long.parseLong(next());

        }

    }
}

