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

public class p1205b {
    private static boolean[] used = new boolean[1000000];
    private static int begin = 0;
    private static int mn = Integer.MAX_VALUE;

    private static final HashMap<Integer, Set<Integer>> adj = new HashMap<>();
    private static final HashMap<Integer, Set<Integer>> adj2 = new HashMap<>();

    static {
        Arrays.fill(used, false);
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        solve(sc);
    }

    public static void solve(Scanner s) {

        int n = s.nextInt();

        HashMap<Integer, Vector<Integer>> map = new HashMap<>();

        Vector<Long> vec = new Vector<>();

        for (int i = 1; i <= n; i++) {
            long o = s.nextLong();
            int k = 1;
            while (o > 0) {
                if ((o & 1L) != 0) {
                    if (!adj.containsKey(k)) {
                        adj.put(k, new HashSet<>());
                    }
                    Set<Integer> setk = adj.get(k);
                    setk.add(i);
                    if (setk.size() > 2) {
//                        System.out.println("adj = " + adj);
                        System.out.println("3");
                        return;
                    }
                }
                k++;
                o >>= 1;
            }
        }

        for (Map.Entry<Integer, Set<Integer>> iter : adj.entrySet()) {
            Set<Integer> v = iter.getValue();
            Iterator<Integer> iterator = v.iterator();
            while (iterator.hasNext()) {
                Integer v1 = iterator.next();
                if (!adj2.containsKey(v1)) {
                    adj2.put(v1, new HashSet<Integer>());
                }
                adj2.get(v1).addAll(v);
            }
        }

        for (Integer integer : adj2.keySet()) {
            begin = integer;
            dfs(integer, 0, 0);
            if (mn == 3) {
                break;
            }
        }

        if (mn == Integer.MAX_VALUE) {
            mn = -1;
        }

        System.out.println(mn);
    }

    public static void dfs(int start, int parent, int distance) {
        if (distance>=mn) {
            return;
        }

        for (Integer i : adj2.get(start)) {
            if (i == begin && parent != begin && parent != 0) {
                mn = mn > distance + 1 ? distance + 1 : mn;
            }

            if (mn == 3) {
                return;
            }
            //adj int
            if (i == start || i == parent || used[i]) {
                continue;
            }
            used[start] = true;
            dfs(i, start, distance + 1);
            used[start] = false;
        }

    }
}
