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 A{
    static PrintWriter out;
    static InputReader in;
    public static void main(String args[]){
        out = new PrintWriter(System.out);
        in = new InputReader();
        new A();
        out.flush(); out.close();
    }   
    A(){
        solve();
    }

    final int maxb = 61;
    final int max = 100010;
    int ans = max;

    ArrayList<Integer> al[] = new ArrayList[maxb];
    ArrayList<Integer> ad[] = new ArrayList[max];

    boolean cy = false;
    int pa[] = new int[max];

    void add(long x, int id){
        int pb = 0;
        while(x != 0){
            if(x % 2 == 1)al[pb].add(id);
            pb++; x >>= 1;
        }
    }

    void merge(int a, int b){
        pa[a] = b;
    }

    int get(int a){
        if(pa[a] == a)return a;
        return pa[a] = get(pa[a]);
    }

    void add(int a, int b){
        // int pa = get(a); int pb = get(b);
        // if(pa != pb){
        //     merge(pa, pb);
        // }else{
        //     cy = false;
        //     dfs(a, 0, b, 0);
        // }
        for(int i = 0; i < ad[a].size(); i++){
            if(ad[a].get(i) == b)return;
        }
        ad[a].add(b); ad[b].add(a);
    }

    void dfs(int u, int pa, int t, int len){
        if(cy)return;
        if(u == t){
            ans = Math.min(ans, len + 1);
            cy = true;
            return;
        }
        for(int v : ad[u]){
            if(v == pa)continue;
            dfs(v, u, t, len + 1);
        }
    }

    int visit[] = new int[max];
    void dfs(int u, int pa, int time){
        visit[u] = time;
        for(int v : ad[u]){
            if(v == pa)continue;
            if(visit[v] != 0){
                ans = Math.min(visit[u] - visit[v] + 1, ans);
                continue;
            }
            dfs(v, u, time + 1);
        }
        visit[u] = 0;
    }

    void solve(){
        int n = in.nextInt();
        for(int i = 0; i < maxb; i++){
            al[i] = new ArrayList<>();
        }
        for(int i = 0; i < n; i++){
            add(in.nextLong(), i + 1);
        }

        for(int i = 0; i < max; i++){
            ad[i] = new ArrayList<>();
            pa[i] = i;
        }

        for(int i = 0; i < maxb; i++){
            int sz = al[i].size();
            if(sz > 2){
                out.print(3); return;
            }
            if(sz == 2){
                add(al[i].get(0), al[i].get(1));
            }
        }
        
        for(int i = 1; i <= n; i++){
            dfs(i, 0, 1);
        }

        if(ans > n){
            out.print(-1); return;
        }
        
        out.print(ans);
    }

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