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.nio.CharBuffer;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class P1205B {

    private static int MAX_BIT = 63;

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        long[] pow = new long[MAX_BIT];
        for (int i = 0; i < MAX_BIT; ++i)
            pow[i] = 1L << i;
        int n = scanner.nextInt();
        ArrayList<Long> a = new ArrayList<>(n);
        int[] cnt = new int[MAX_BIT];
        for (int i = 0; i < n; ++i) {
            long t = scanner.nextLong();
            if (t != 0) {
                for (int j = 0; j < MAX_BIT; ++j) {
                    if ((t & pow[j]) > 0)
                        ++cnt[j];
                }
                a.add(t);
            }
        }
        boolean more3 = false;
        int ans = n + 1;
        for (int i = 0; i < MAX_BIT; ++i) {
            if (cnt[i] >= 3) {
                more3 = true;
                ans = 3;
                break;
            }
        }
        if (!more3) {
//            writer.println("floyd");
            n = a.size();
            int[][] matrix = new int[n][n];
            int[][] dis = new int[n][n];
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < n; ++j) {
                    if (i != j && (a.get(i) & a.get(j)) > 0) {
                        dis[i][j] = matrix[i][j] = 1;
                    } else {
                        dis[i][j] = matrix[i][j] = n + 1;
                    }
                }
            }
            for (int k = 0; k < n; ++k) {
                for (int i = 0; i < k; ++i)
                    for (int j = 0; j < i; ++j)
                        ans = Math.min(ans, dis[i][j] + matrix[i][k] + matrix[k][j]);
                for (int i = 0; i < n; ++i)
                    for (int j = 0; j < n; ++j)
                        dis[i][j] = Math.min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
        writer.println(ans <= n ? ans : -1);
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
