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.math.*;
 
public class Main
{
    static int shortest_cycle(int n, int start_idx, ArrayList<Integer> l[]){
        int res = oo, dist[] = new int[n + 1], par[] = new int[n + 1];
        Queue<Integer> q = new LinkedList<>();

        for(int i = start_idx; i <= n; i++){
            Arrays.fill(dist, oo);
            Arrays.fill(par, 0);
            dist[i] = 0;
            q.add(i);

            while(!q.isEmpty()){
                int node = q.poll();
                for(int adj : l[node]){
                    if(dist[adj] == oo){
                        par[adj] = node;
                        q.add(adj);
                        dist[adj] = 1 + dist[node];
                    }
                    else if(par[adj] != node && par[node] != adj){
                        res = Math.min(res, dist[node] + dist[adj] + 1);
                    }
                }
            }

            q.clear();
        }

        return res;
    }

    public static void process(int test_number)throws IOException
    {
        int n = ni(), cnt_0 = 0;
        long arr[] = new long[n + 1], bit_count[] = new long[60 + 1];
        for(int i = 1; i <= n; i++){
            arr[i] = nl();  
            if(arr[i] == 0) cnt_0++;    
        }

        boolean flag = false;
        for(int i = 1; i <= n; i++){
            long tmp = arr[i];
            int pos = 0;
            while(tmp != 0){
                if((tmp & 1) == 1)
                    bit_count[pos]++;
                tmp /= 2l;

                if(bit_count[pos] >= 3)
                    flag = true;

                pos++;
            }
        }

        if(flag)
            pn(3);
        else{
            ArrayList<Integer> l[] = new ArrayList[n + 1];
            for(int i = 1; i <= n; i++)
                l[i] = new ArrayList<>();
            custom_sort(arr, n);
            int start_idx = 1;
            if(cnt_0 != 0) start_idx = cnt_0 + 1;

            for(int i = start_idx; i <= n; i++){
                for(int j = i + 1; j <= n; j++){
                    if((arr[i] & arr[j]) != 0l){
                        l[i].add(j);
                        l[j].add(i);
                    }
                }
            }

            int res = shortest_cycle(n, start_idx, l);
            pn(res >= oo ? -1 : res);
        }
    }
         
    static void custom_sort(long arr[], int n){
        ArrayList<Long> li = new ArrayList<>();
        for(int i = 1; i <= n; i++)
            li.add(arr[i]);
        Collections.sort(li);

        for(int i = 1; i <= n; i++){
            arr[i] = li.get(i - 1);
        }
    }
    static final int oo = (int) 1e9;
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(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(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}
