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.stream.LongStream;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author null
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Input in = new Input(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, Input in, PrintWriter out) {
            try {
                int n = in.readInt();
                List<Long> list = new ArrayList<>(n);
                for (int i = 0; i < n; i++) {
                    long x = in.readLong();
                    if (x != 0) {
                        list.add(x);
                    }
                }
                long[] a = list.stream().mapToLong(x -> x).toArray();
                n = a.length;

                for (long m = 1; m < Long.MAX_VALUE / 2 - 1; m <<= 1) {
                    int c = 0;
                    for (int i = 0; i < n; i++) {
                        if ((a[i] & m) != 0) {
                            c++;
                        }
                    }
                    if (c >= 3) {
                        out.println(3);
                        return;
                    }
                }

                int ans = Integer.MAX_VALUE;
                for (int v = 0; v < n; v++) {
                    for (int u = v + 1; u < n; u++) {
                        if ((a[v] & a[u]) != 0) {
                            int[] q = new int[n];
                            q[0] = v;
                            int L = 0;
                            int R = 1;

                            boolean[] b = new boolean[n];
                            b[v] = true;

                            int d = 0;
                            while (L < R) {
                                d++;
                                int r = R;
                                for (int i = L; i < r && !b[u]; i++) {
                                    for (int j = 0; j < n && !b[u]; j++) {
                                        if (d == 1 && j == u) {
                                            continue;
                                        }
                                        if (!b[j] && (a[q[i]] & a[j]) != 0) {
                                            q[R] = j;
                                            R++;
                                            b[j] = true;
                                            if (j == u && d + 1 < ans) {
                                                ans = d + 1;
                                            }
                                        }
                                    }
                                }
                                L = r;
                            }
                        }
                    }
                }

                out.println((ans != Integer.MAX_VALUE) ? ans : -1);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

    }

    static class Input {
        public final BufferedReader reader;
        private String line = "";
        private int pos = 0;

        public Input(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

        private boolean isSpace(char ch) {
            return ch <= 32;
        }

        public String readWord() throws IOException {
            skip();
            int start = pos;
            while (pos < line.length() && !isSpace(line.charAt(pos))) {
                pos++;
            }
            return line.substring(start, pos);
        }

        public int readInt() throws IOException {
            return Integer.parseInt(readWord());
        }

        public long readLong() throws IOException {
            return Long.parseLong(readWord());
        }

        private void skip() throws IOException {
            while (true) {
                if (pos >= line.length()) {
                    line = reader.readLine();
                    pos = 0;
                }
                while (pos < line.length() && isSpace(line.charAt(pos))) {
                    pos++;
                }
                if (pos < line.length()) {
                    return;
                }
            }
        }

    }
}

