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.HashSet;
import java.util.Arrays;
import java.util.Collection;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Deque;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Puneet    //FastRead class is taken from different online Sources
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastInput in = new FastInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, FastInput in, PrintWriter out) {
            int n = in.ni();
            long[] arr = in.longarr(n);
            ArrayList<Integer>[] adj = new ArrayList[64];
            for (int i = 0; i < 64; i++) {
                adj[i] = new ArrayList<>();
            }

            int ans = Integer.MAX_VALUE;
            for (long i = 0; i <= 60; i++) {

                for (int j = 0; j < n; j++) {
                    int bit = (((1L << i) & (arr[j]))) > 0 ? 1 : 0;
                    if (bit > 0) {
                        adj[(int) i].add(j);
                    }
                }
            }

            for (int i = 0; i <= 60; i++) {
                if (adj[i].size() > 2) {
                    out.println("3");
                    return;
                }
            }

            HashSet<Integer>[] graph = new HashSet[n];
            for (int i = 0; i < n; i++) {
                graph[i] = new HashSet<>();
            }

            for (int i = 0; i <= 60; i++) {
                for (int j : adj[i]) {
                    for (int k : adj[i]) {
                        if (j != k) {
                            graph[j].add(k);
                        }
                    }
                }
            }
            for (int u = 0; u < n; u++) {
                if (graph[u].size() <= 1)
                    continue;
                int value = mindist(graph, u, n);
//          out.println(value);
                ans = Math.min(ans, value);

            }

            out.println(ans == Integer.MAX_VALUE ? -1 : ans);


        }

        private int mindist(HashSet<Integer>[] g, int s, int n) {
            int[] dist = new int[n];
            int[] prev = new int[n];
            Arrays.fill(dist, -1);
            Arrays.fill(prev, -1);
            Deque<Integer> q = new ArrayDeque<>();
            q.add(s);
            dist[s] = 0;
            int min = Integer.MAX_VALUE;
            while (!q.isEmpty()) {
                int u = q.pollFirst();
                for (int v : g[u]) {
                    if (dist[v] < 0) {
                        dist[v] = dist[u] + 1;
                        prev[v] = u;
                        q.add(v);
                    } else if (prev[u] != v) {
                        int tot = dist[u] + dist[v] + 1;
                        min = Integer.min(min, tot);
                    }
                }
            }
            return min;
        }

    }

    static class FastInput {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastInput.SpaceCharFilter filter;

        public FastInput(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long[] longarr(int n) {
            long arr[] = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nl();
            }
            return arr;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

