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.*;
import java.io.*;

public class ShortestCycle {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = scanner.nextInt();
        long[] arr = new long[n];
        for(int i = 0; i < n; i++) arr[i] = scanner.nextLong();
        Pair[][] cnt = new Pair[60][2];
        int[] v = new int[60];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < 60; j++) {
                if (((1L << j) & arr[i]) > 0) {
                    if (v[j] == 2) {
                        out.println(3);
                        out.flush();
                        return;
                    }
                    else {
                        cnt[j][v[j]++] = new Pair(arr[i], i);;
                    }
                }
            }
        }
        //for(int i = 0; i < 60; i++) {
        //    out.println(i + ": " + cnt[i][0] + " " + cnt[i][1]);
        //}
        int best = Integer.MAX_VALUE;
        for(int i = 0; i < 60; i++) {
            best = Math.min(best, bfs(cnt[i][0], cnt[i][1], cnt));
        }
        if (best == Integer.MAX_VALUE) out.println(-1);
        else out.println(best);
        out.flush();
    }

    static int bfs(Pair p1, Pair p2, Pair[][] cnt) {
        ArrayDeque<Pair> queue = new ArrayDeque<>();
        if (p1 == null || p2 == null) return Integer.MAX_VALUE;
        int[][] dists = new int[60][2];
        for(int i = 0; i  < 60; i++) {
            dists[i][0] = -1;
            dists[i][1] = -1;
        }
        for(int i = 0; i < 60; i++) {
            for(int j = 0; j < 2; j++) {
                if (cnt[i][j] == null) continue;
                if (cnt[i][j].a == p1.a && cnt[i][j].b == p1.b) {
                    dists[i][j] = 0;
                    queue.offer(new Pair(i,j));
                }
            }
        }
        while(!queue.isEmpty()) {
            Pair cur = queue.poll();
            int opp = 1-cur.b;
            int a = (int)cur.a;
            if (cnt[a][opp] == null) continue;
            if (dists[a][opp] != -1) continue;
            if (cnt[a][opp].a == p2.a && cnt[a][opp].b == p2.b ) {
                if(cnt[a][cur.b].a != p1.a || cnt[a][cur.b].b != p1.b) {
                    return dists[a][cur.b] + 2;
                }
                else continue;
            }
            dists[a][opp] = dists[a][cur.b] + 1;
            for(int i = 0; i < 60; i++) {
                for(int j = 0; j < 2; j++) {
                    if (cnt[i][j] == null) continue;
                    if (cnt[i][j].a == cnt[a][opp].a && cnt[i][j].b == cnt[a][opp].b) {
                       dists[i][j] = dists[a][opp];
                      queue.offer(new Pair(i, j)); 
                    }
                }
            }
        }
        return Integer.MAX_VALUE;
    }
    
    static class Pair {
        long a; int b;
        public Pair(long aa, int bb) {
            a = aa; b=bb;
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
