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.OutputStream;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.HashSet;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.ArrayDeque;
import java.io.InputStream;

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

    static class BShortestCycle {
        int N;
        Long[] A;
        HashSet<Integer>[] graph;

        public void solve(int testNumber, FastReader in, FastWriter out) {
            int i, j, k;

            N = in.nextInt();
            A = new Long[N];
            for (i = 0; i < N; ++i) A[i] = in.nextLong();
            Arrays.sort(A);

            for (i = 0; i < N && A[i] == 0; ++i) ;
            Long[] temp = new Long[N - i];
            for (k = 0; i < N; ++i) temp[k++] = A[i];
            N = temp.length;
            A = temp;

            if (N >= 130) {
                out.println(3);
                out.flush();
                return;
            }


            graph = new HashSet[N];
            for (i = 0; i < N; ++i) graph[i] = new HashSet<>();

            for (i = 0; i < N; ++i)
                for (j = 0; j < i; ++j)
                    if ((A[i] & A[j]) > 0) {
                        graph[i].add(j);
                        graph[j].add(i);
                    }

            int ans = Integer.MAX_VALUE >> 2;
            for (i = 0; i < N; ++i)
                for (j = 0; j < i; ++j)
                    if ((A[i] & A[j]) > 0) {
                        graph[i].remove(j);
                        graph[j].remove(i);
                        ans = Math.min(ans, bfs(i, j));
                        graph[i].add(j);
                        graph[j].add(i);
                    }

            out.println(ans > N ? -1 : ans);
            out.flush();
        }

        int bfs(int start, int target) {
            ArrayDeque<Integer> queue = new ArrayDeque<>();
            int[] depth = new int[N];
            depth[start] = 1;
            queue.add(start);
            while (!queue.isEmpty()) {
                int top = queue.pollFirst(), dep = depth[top];
                for (int itr : graph[top])
                    if (depth[itr] == 0) {
                        depth[itr] = dep + 1;
                        queue.add(itr);
                        if (itr == target) return depth[itr];
                    }
            }
            return Integer.MAX_VALUE >> 2;
        }

    }

    static class FastReader {
        static private byte[] buf = new byte[2048];
        static private int index;
        static private int total;
        static private InputStream in;

        public FastReader(InputStream is) {
            try {
                in = is;
            } catch (Exception e) {
            }
        }

        private int scan() {
            try {
                if (index >= total) {
                    index = 0;
                    total = in.read(buf);
                    if (total <= 0)
                        return -1;
                }
                return buf[index++];
            } catch (Exception e) {
                return 7 / 0;
            }
        }

        public int nextInt() {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+')
                c = scan();
            for (; c >= '0' && c <= '9'; c = scan())
                val = (val << 3) + (val << 1) + (c & 15);
            return neg ? -val : val;
        }

        public long nextLong() {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+')
                c = scan();
            for (; c >= '0' && c <= '9'; c = scan())
                val = (val << 3) + (val << 1) + (c & 15);
            return neg ? -val : val;
        }

    }

    static class FastWriter {
        static private BufferedWriter bw;

        public FastWriter(OutputStream os) {
            bw = new BufferedWriter(new OutputStreamWriter(os));
        }

        public FastWriter(Writer w) {
            bw = new BufferedWriter(w);
        }

        public void print(Object a) {
            try {
                bw.write(a.toString());
            } catch (Exception e) {
            }
        }

        public void println(Object a) {
            print(a);
            print("\n");
        }

        public void flush() {
            try {
                bw.flush();
            } catch (Exception e) {
            }
        }

        public void close() {
            try {
                bw.close();
            } catch (Exception e) {
            }
        }

    }
}

