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.util.Arrays;
import java.util.HashMap;
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.io.InputStream;

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

    static class DShortestCycle {
        static int ans;
        static ArrayList<Integer> comp;
        static DShortestCycle.Node[] graph;
        static int[] visited;
        static boolean[] used;

        static void dfs(int a, int depth, int par) {
            visited[a] = depth;
            for (int i : graph[a].edges) {
                if (i == par)
                    continue;
                if (visited[i] != 0) {
                    ans = Math.min(ans, depth - visited[i]);
                } else {
                    dfs(i, depth + 1, a);
                }
            }
            visited[a] = 0;
        }

        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            graph = new DShortestCycle.Node[n];
            for (int i = 0; i < n; i++) {
                graph[i] = new DShortestCycle.Node();
                graph[i].edges = new TreeSet<>();
            }


            long[] tab = new long[n];
            long max = 0;
            for (int i = 0; i < n; i++) {
                tab[i] = sc.nextLong();
                max = Math.max(max, tab[i]);
            }
            int len = Long.toBinaryString(max).length();
            char[][] bin = new char[n][len];
            for (int i = 0; i < n; i++) {
                Arrays.fill(bin[i], '0');
            }
            for (int i = 0; i < n; i++) {
                String act = Long.toBinaryString(tab[i]);
                for (int j = 0; j < act.length(); j++) {
                    bin[i][len - 1 - j] = act.charAt(act.length() - 1 - j);
                }
            }

            for (int i = 0; i < len; i++) {
                int act = 0;
                int which1 = -1, which2 = -1;
                for (int j = 0; j < n; j++) {
                    if (bin[j][i] == '1') {
                        act++;
                        if (act >= 3) {
                            out.println("3");
                            return;
                        }
                        if (which1 == -1) {
                            which1 = j;
                        } else {
                            which2 = j;
                        }
                    }
                    if (act == 2) {
                        graph[which1].edges.add(which2);
                        graph[which2].edges.add(which1);
                    }
                }
            }
            comp = new ArrayList<>();
            ans = 1000000000;
            visited = new int[n];
            used = new boolean[n];
            HashMap<Integer, Integer> rep = new HashMap<>();
            for (int i = 0; i < n; i++) {
                dfs(i, 1, -1);
            }
            if (ans == 1000000000) {
                out.println(-1);
            } else {
                out.println(ans + 1);
            }

        }

        static class Node {
            TreeSet<Integer> edges;

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

