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

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

    static class ShortestCycle {
        int n;
        List<Long> a;
        int ans;
        List<Integer>[] adj;

        void bfs(int s) {
            boolean[] vis = new boolean[a.size()];
            int[] d = new int[a.size()];
            int[] p = new int[a.size()];
            Arrays.fill(p, -1);
            d[s] = 0;
            Queue<Integer> q = new ArrayDeque<>();
            q.add(s);
            vis[s] = true;
            while (!q.isEmpty()) {
                int u = q.poll();
                for (int v : adj[u]) {
                    if (!vis[v]) {
                        d[v] = d[u] + 1;
                        vis[v] = true;
                        p[v] = u;
                        q.add(v);
                    } else if (p[v] != u && p[u] != v) {
                        ans = Math.min(ans, d[u] + d[v] + 1);
                    }
                }
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.ni();
            a = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                long x = in.nl();
                if (x != 0) {
                    a.add(x);
                }
            }

            if (a.size() >= 121) {
                out.println(3);
                return;
            }

            adj = new List[a.size()];
            Arrays.setAll(adj, i -> new ArrayList<>());
            for (int i = 0; i < a.size(); i++) {
                for (int j = 0; j < a.size(); j++) {
                    if (i == j) {
                        continue;
                    }
                    if ((a.get(i) & a.get(j)) != 0) {
                        adj[i].add(j);
                        adj[j].add(i);
                    }
                }
            }

            ans = Integer.MAX_VALUE;
            for (int i = 0; i < a.size(); i++) {
                bfs(i);
            }

            if (ans == Integer.MAX_VALUE) {
                out.println(-1);
            } else {
                out.println(ans);
            }
        }

    }

    static class InputReader {
        private final InputStream is;
        private final byte[] inbuf = new byte[1024];
        private int lenbuf = 0;
        private int ptrbuf = 0;

        public InputReader(InputStream stream) {
            is = stream;
        }

        private int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = is.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public int ni() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public long nl() {
            long num = 0;
            int b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}

