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

public class Main {
    private final FastRead reader;
    private final FastWrite writer;

    private static int dfs(long[] arr, int[] depth, int it, int prev) {
        int curMin = arr.length;
        for (int i = 0; i < arr.length; ++i) {
            if (i == it) continue;
            if ((arr[i] & arr[it]) == 0) continue;
            if (depth[i] == 0) {
                depth[i] = depth[it]+1;
                int sub = dfs(arr, depth, i, it);
                if (sub < curMin)
                    curMin = sub;
            } else if (i != prev && depth[i] > 0 && depth[it] - depth[i] < curMin) {
                curMin = depth[it] - depth[i];
            }
        }
        depth[it] *= -1;
        return curMin;
    }

    private static int solve(long[] arr) {
        /* remove zeros */ {
            int n = 0;
            for (long x : arr)
                if (x == 0)
                    ++n;
            if (n != 0) {
                long[] oldArr = arr;
                arr = new long[arr.length - n];
                n = 0;
                for (long x : oldArr)
                    if (x != 0)
                        arr[n++] = x;
            }
        }

        /* clique test */ {
            if (arr.length > 128)
                return 3;
            int[] cliqueSizes = new int[63];
            for (long x : arr)
                for (int i = 0; i < cliqueSizes.length; ++i)
                    if ((x & (1L << i)) != 0)
                        if (3 == ++cliqueSizes[i])
                            return 3;
        }

        /* stupid solve */ {
            int n = arr.length;
            int[] depth = new int[n];
            int res = n;
            for (int i = 0; i < n; ++i) {
                Arrays.fill(depth, 0);
                depth[i] = 1;
                int curRes = dfs(arr, depth, i, -1);
                if (curRes < res)
                    res = curRes;
            }

            return (res == n) ? -1 : (res+1);
        }
    }

    private void run() throws Exception {
        int n = reader.nextInt();
        long[] arr = new long[n];
        for (int i = 0; i < n; ++i)
            arr[i] = reader.nextLong();
        writer.println("" + solve(arr));
    }

    /* ====================== Template ====================== */
    public static void main(String[] args) throws Exception {
        Main m = new Main();
        try { m.run(); } finally { m.writer.flush(); }
    }

    private Main() {
        reader = new FastRead(System.in);
        writer = new FastWrite(System.out);
    }

    static final int BUFFER_SIZE = 1<<16;
    static class FastRead {
        private final InputStream in;
        private final byte[] buffer;
        private int cur, ready;

        private void refillBuffer() throws IOException {
            ready = in.read(buffer, 0, buffer.length);
            cur = (ready == -1) ? -1 : 0;
        }

        public FastRead(InputStream in) {
            this.in = in;
            buffer = new byte[BUFFER_SIZE];
            cur = ready = 0;
        }

        private byte read() throws IOException {
            if (cur == ready) refillBuffer();
            return buffer[cur++];
        }

        public String nextString(int maxLength) throws IOException {
            byte[] res = new byte[maxLength];
            int len =  0;
            byte c = read();
            while (c == ' ' || c == '\n' || c=='\r')
                c = read();
            while (c != ' ' && c != '\n' && c!='\r') {
                res[len++] = c;
                c = read();
            }
            return new String(res, 0, len);
        }

        public String nextString() throws IOException {
            byte[] res = new byte[64];
            int len =  0;
            byte c = read();
            while (c == ' ' || c == '\n' || c=='\r')
                c = read();
            while (c != ' ' && c != '\n' && c!='\r') {
                if (len == res.length) {
                    byte[] oldRes = res;
                    res = new byte[res.length * 4];
                    System.arraycopy(oldRes, 0, res, 0, oldRes.length);
                }
                res[len++] = c;
                c = read();
            }
            return new String(res, 0, len);
        }

        public int nextInt() throws IOException {
            int ret =  0;
            boolean neg;

            byte c = read();
            while (c <= ' ')
                c = read();
            neg = c == '-';
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
                c = read();
            } while (c > ' ');

            return neg ? -ret : ret;
        }

        public long nextLong() throws IOException {
            long ret =  0;
            boolean neg;

            byte c = read();
            while (c <= ' ')
                c = read();
            neg = c == '-';
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
                c = read();
            } while (c > ' ');

            return neg ? -ret : ret;
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(nextString(32));
        }

        public float nextFloat() throws IOException {
            return Float.parseFloat(nextString(32));
        }

        public void close() throws IOException {
            in.close();
        }
    }
    static class FastWrite {
        private final OutputStream out;
        private final byte[] buffer;
        private int ready;

        public FastWrite(OutputStream out) {
            this.out = out;
            buffer = new byte[BUFFER_SIZE];
            ready = 0;
        }

        public void flush() throws IOException {
            if (ready > 0) {
                out.write(buffer, 0, ready);
                ready = 0;
            }
        }

        private void put(byte b) throws IOException {
            if (ready == buffer.length) flush();
            buffer[ready++] = b;
        }

        private void put(byte[] b) throws IOException {
            int done = 0;
            if (ready < buffer.length) {
                done = buffer.length - ready;
                if (done > b.length) done = b.length;
                System.arraycopy(b, 0, buffer, ready, done);
                ready += done;
            }

            if (ready == buffer.length) flush();
            if (done == b.length) return;
            assert ready == 0;

            if ((b.length - done) * 2 < buffer.length) {
                ready = b.length - done;
                System.arraycopy(b, done, buffer, 0, ready);
            } else {
                out.write(b, done, b.length - done);
            }
        }

        public void print(String s) throws IOException {
            put(s.getBytes());
        }

        public void println(String s) throws IOException {
            put(s.getBytes()); put((byte)'\n');
        }

        public void println() throws IOException {
            put((byte)'\n');
        }
    }
}
