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.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC)throws Exception{
        int n = ni();
        int B = 60;
        int[][] list = new int[B][2];
        for(int i = 0; i< B; i++)list[i] = new int[]{-1, -1};
        int[] cnt = new int[B];
//        int[][] m = new int[B][B];
//        int[] cnt = new int[B];
        int ans = 100000000;
        int[][] e = new int[B][];int c = 0;
        for(int i = 0; i< n && ans > 3; i++){
            long x = nl();
            
            for(int j = 0; j< B; j++){
                if(((x>>j)&1)==1){
                    if(cnt[j] == 2){
                        ans = 3;break;
                    }
                    list[j][cnt[j]++] = i;
                }
            }
        }
        if(ans == 3){
            pn(3);
            return;
        }
        for(int i = 0; i< B; i++)
            if(cnt[i] == 2){
                boolean sk = false;
                for(int j = 0; j< i; j++)if(list[j][0] == list[i][0] && list[j][1] == list[i][1])sk = true;
                if(!sk)e[c] = new int[]{list[i][0], list[i][1], c++};
            }
        e = Arrays.copyOfRange(e, 0, c);
        int[][][] g = makeUS(n, e);
        int[] d = new int[n];
        Arrays.fill(d, n+2);
            
        for(int i = 0; i< c; i++){
            Queue<Integer> q = new ArrayDeque<>();
            TreeSet<Integer> st = new TreeSet<>();
            q.add(e[i][0]);
            d[e[i][0]] = 0;
            while(!q.isEmpty()){
                int u = q.poll();
                st.add(u);
                for(int[] v:g[u]){
                    if(v[1] == i || d[v[0]] <= d[u]+1)continue;
                    d[v[0]] = d[u]+1;
                    q.add(v[0]);
                }
            }
            if(d[e[i][1]] < n)ans = Math.min(ans, 1+d[e[i][1]]);
            for(int x:st)d[x] = n+2;
        }
        if(ans > n)ans = -1;
        pn(ans);
    }
    int[][][] makeUS(int n, int[][] edge){
        int[][][] g = new int[n][][];int[] cnt = new int[n];
        for(int i = 0; i< edge.length; i++){cnt[edge[i][0]]++;cnt[edge[i][1]]++;}
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]][];
        for(int i = 0; i< edge.length; i++){
            g[edge[i][0]][--cnt[edge[i][0]]] = new int[]{edge[i][1], edge[i][2]};
            g[edge[i][1]][--cnt[edge[i][1]]] = new int[]{edge[i][0], edge[i][2]};
        }
        return g;
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    void exit(boolean b){if(!b)System.exit(0);}
    long IINF = (long)1e18, mod = (long)998244353;
    final int INF = (int)1e9, MX = (int)2e6+5;
    DecimalFormat df = new DecimalFormat("0.00000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-6;
    static boolean multipleTC = false, memory = false, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        if(fileIO){
            in = new FastReader("input.txt");
            out = new PrintWriter("output.txt");
        }else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();
        for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    
    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}
 
    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }
 
        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }
 
        String nextLine() throws Exception{
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }  
            return str;
        }
    }
}  