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

public class Main {
    void solve(){
        int n=ni();
        long a[]=new long[n+1];
        for(int i=1;i<=n;i++) a[i]=nl();
        ArrayList<Integer> list[]=new ArrayList[62];
        for(int i=0;i<62;i++) list[i]=new ArrayList<>();
        for(int i=1;i<=n;i++) {
            for(int j=0;j<62;j++){
                if(((a[i]>>j)&1)==1){
                    list[j].add(i);

                }
            }

        }
        for(int j=0;j<62;j++){
            if(list[j].size()>2){
                pw.println("3");
                return;
            }
        }

        HashSet<Pair> hs=new HashSet<>();
        PriorityQueue<Integer> pq=new PriorityQueue<>();
        for(int i=0;i<62;i++){
            if(list[i].size()==2){
                int u=list[i].get(0),v=list[i].get(1);
                pq.offer(u); pq.offer(v);

            }
        }
        HashMap<Integer,Integer> mp=new HashMap<>();
        int m=0;
        while(!pq.isEmpty()){
            int u=pq.poll();
            if(!mp.containsKey(u)){
                mp.put(u,++m);
            }
        }
        g=new ArrayList[m+1];
        for(int i=1;i<=m;i++) g[i]=new ArrayList<>();
        for(int i=0;i<62;i++){
            if(list[i].size()==2){
                int u=list[i].get(0),v=list[i].get(1);
                u=mp.get(u); v=mp.get(v);
                if(!hs.contains(new Pair(u,v))){
                    hs.add(new Pair(u,v));
                    hs.add(new Pair(v,u));
                    g[u].add(v); g[v].add(u);

                }
            }
        }


        dp=new int[m+1];
        ans=Integer.MAX_VALUE;
        boolean vis[][]=new boolean[m+1][m+1];
        for(int u=1;u<=m;u++){
            for(int v : g[u]){
                if(vis[u][v]) continue;
                vis[u][v]=vis[v][u]=true;
                diji(u,u,v);
                if(dp[v]!=Integer.MAX_VALUE)
                ans=Math.min(ans,dp[v]+1);
            }
        }





        if(ans==Integer.MAX_VALUE) ans=-1;
        pw.println(ans);

    }
    ArrayList<Integer> g[];
    int ans;
    int dp[];
    Queue<Pair> q=new PriorityQueue<>();
    void diji(int st,int X,int Y){
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[st]=0;
        q.clear();
        q.offer(new Pair(st,0));
        while(!q.isEmpty()){
            Pair p = q.poll();
            for(int v : g[p.u]){
                if((p.u==X && v==Y) || (p.u==Y && v==X)) continue;
                if(dp[p.u]+1<dp[v]){
                    dp[v]=dp[p.u]+1;
                    q.offer(new Pair(v,dp[v]));
                }
            }
        }
    }

    class Pair implements Comparable<Pair>{
        int u;
        int v;
        public Pair(int u,int v){
            this.u=u;
            this.v=v;
        }
        public boolean equals(Object o){
            Pair c=(Pair)o;
            return u==c.u && v==c.v;
        }
        public int compareTo(Pair c){
            return Integer.compare(this.v,c.v);
        }

    }

    long M = (long)1e9+7;


    // END
    PrintWriter pw;
    StringTokenizer st;
    BufferedReader br;

    void run() throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    String ns() {
        while (st == null || !st.hasMoreElements()) {

            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }

    int ni() {
        return Integer.parseInt(ns());
    }

    long nl() {
        return Long.parseLong(ns());
    }

    double nd() {
        return Double.parseDouble(ns());
    }
}