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.util.*;

import static java.lang.Math.min;


/**
 * Created by Katushka on 11.03.2020.
 */
public class C {

    public static final Comparator<int[]> COMPARATOR = Comparator.comparingInt(o -> o[0]);

    static int[] readArray(int size, InputReader in) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextInt();
        }
        return a;
    }

    static long[] readLongArray(int size, InputReader in) {
        long[] a = new long[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextLong();
        }
        return a;
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = in.nextInt();
        long[] a = readLongArray(n, in);
        int[][] bits = new int[n][70];
        for (int i = 0; i < n; i++) {
            int j = 0;
            long ai = a[i];
            while (ai > 0) {
                bits[i][70 - j - 1] = (int) (ai % 2);
                j += 1;
                ai /= 2;
            }
        }

        for (int i = 0; i < 70; i++) {
            int cntOnes = 0;
            for (int j = 0; j < n; j++) {
                if (bits[j][i] == 1) {
                    cntOnes++;
                    if (cntOnes >= 3) {
                        out.println(3);
                        out.close();
                        return;
                    }
                }
            }
        }

        Map<Integer, Set<Integer>> graph = new HashMap<>();
        boolean[] used = new boolean[n];
        for (int i = 0; i < 70; i++) {
            int v1 = -1;
            for (int j = 0; j < n; j++) {
                if (bits[j][i] == 1) {
                    if (v1 == -1) {
                        v1 = j;
                    } else {
                        if (!graph.containsKey(v1)) {
                            graph.put(v1, new HashSet<>());
                        }
                        if (!graph.containsKey(j)) {
                            graph.put(j, new HashSet<>());
                        }
                        used[v1] = true;
                        used[j] = true;
                        graph.get(v1).add(j);
                        graph.get(j).add(v1);
                    }
                }
            }

        }

        int res = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            if (!used[i]) {
                continue;
            }

            res = min(res, shortestCycle(graph, i, n));
        }
        if (res == Integer.MAX_VALUE) {
            out.println(-1);
        } else {
            out.println(res);
        }
        out.close();
    }

    private static int shortestCycle(Map<Integer, Set<Integer>> graph, int start, int n) {
        Queue<Integer> q = new LinkedList<>();
        q.add(start);
        boolean[] used = new boolean[n];
        int[] d = new int[n];
        int[] p = new int[n];
        used[start] = true;
        p[start] = -1;
        while (!q.isEmpty()) {
            int v = q.poll();
            if (!graph.containsKey(v)) {
                continue;
            }
            for (Integer to : graph.get(v)) {
                if (!used[to]) {
                    used[to] = true;
                    q.add(to);
                    d[to] = d[v] + 1;
                    p[to] = v;
                } else if (to != p[v]) {
                    return d[to] + d[v] + 1;
                }
            }
        }
        return Integer.MAX_VALUE;
    }

    private static void outputArray(List<Integer> ans, PrintWriter out) {
        StringBuilder str = new StringBuilder();
        for (int an : ans) {
            str.append(an).append(" ");
        }
        out.println(str);
    }

    private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextString() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }
    }
}