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.
 //package Contest580;

import javafx.util.Pair;

import java.io.*;
import java.util .*;

import java.util.StringTokenizer;

public class mainD {
    public static PrintWriter out = new PrintWriter(System.out);
    public static FastScanner enter = new FastScanner(System.in);
    public static int[][] arr;
    static HashSet<Pair> washere=new HashSet<>();
    public static void main(String[] args) throws IOException {
        int n=enter.nextInt();
        arr=new int[n+1][80];
        for (int i = 1; i <n+1 ; i++) {
            long val=enter.nextLong();
            int index=0;
            while(val!=0){
                long r=val%2;
                arr[i][index]=(int)r;
                val/=2;
                index++;
            }
        }

        Graph g = new Graph(n);

        for (int i = 0; i <80 ; i++) {
            long summ=0;
            int a=-1;
            int b=-1;
            for (int j = 1; j <n+1 ; j++) {
                summ+=arr[j][i];
                if(arr[j][i]==1){
                    b=j;
                    if(a==-1) a=j;
                }
            }
            if(summ>=3) {
                System.out.println(3);
                return;
            }
            if(summ==2){
                if(washere.contains(new Pair(Math.min(a,b), Math.max(a,b)))) continue;
                g.add(a,b);
                g.add(b,a);
                washere.add(new Pair(Math.min(a,b), Math.max(a,b)));
            }
        }
       // g.cout_tree();



        g.solve();
        out.close();
    }
    static class Pair{
        int x;
        int y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair pair = (Pair) o;
            return x == pair.x &&
                    y == pair.y;
        }

        @Override
        public int hashCode() {

            return Objects.hash(x, y);
        }
    }



    static class Graph {
        int n;
        int m;
        LinkedList<Integer>[] vert;
        HashMap<pair, Long> ed;
        boolean used[];

        static class pair {
            int u, w;

            public pair(int u, int w) {
                this.u = u;
                this.w = w;
            }

            @Override
            public boolean equals(Object o) {
                if (this == o) return true;
                if (o == null || getClass() != o.getClass()) return false;
                pair pair = (pair) o;
                return u == pair.u &&
                        w == pair.w;
            }

            @Override
            public int hashCode() {

                return Objects.hash(u, w);
            }
        }

        public Graph(int n) {
            this.n = n;
            vert = new LinkedList[n + 1]; //1 ,...., n
            for (int i = 1; i < n + 1; i++) vert[i] = new LinkedList<>();
            used = new boolean[n + 1];
            ed = new HashMap<>();
        }

        public Graph(int n, int m) {
            this.n = n;
            vert = new LinkedList[n + 1]; //1 ,...., n
            for (int i = 1; i < n + 1; i++) vert[i] = new LinkedList<>();
            //edge = new ArrayList<>(); //0 ,...., m-1
            used = new boolean[n + 1];
            ed = new HashMap<>();
        }

        public void add(int a, int b) {
            vert[a].addLast(b);
            //vert[b].addLast(a);
            /*if (edge != null) {
                edge.add(new Pair<>(a, b));
            }*/
        }

        public void add(int a, int b, long w) {
            vert[a].addLast(b);

            ed.put(new pair(a, b), w);
        }


        public void solve(){
            DFS();

        }


        static int distance[];
        static int[] from;

        int getMinCicle(int v, boolean[] was){


            LinkedList<Integer> queue=new LinkedList<>();
            queue.add(v);
            was[v]=true;
            int ans=Integer.MAX_VALUE;
            while(!queue.isEmpty()) {
                int now=queue.pollFirst();
                for (int n : vert[now]) {
                    if (!was[n]) {
                        from[n]=now;
                        distance[n] = distance[now] + 1;
                        queue.addLast(n);
                        was[n]=true;
                    }
                    else{
                        if(from[now]!=n) ans=Math.min(distance[n]+distance[now]+1, ans);
                    }
                }

            }
            return ans;
        }

        void DFS() {
            boolean was[] = new boolean[n + 1];
            distance=new int[n+1];
            from=new int[n+1];
            int ans=Integer.MAX_VALUE;
            for (int i = 1; i <n+1 ; i++) {
                if(vert[i].size()!=0){
                    Arrays.fill(was, false);
                    Arrays.fill(distance, 0);
                    ans=Math.min(getMinCicle(i, was), ans);
                }
            }
            System.out.println((ans==Integer.MAX_VALUE)? -1:ans);
        }

        public void cout_tree() {
            for (int i = 1; i < n + 1; i++) {
                out.println(i + " ");
                out.println(vert[i]);
            }
        }


    }


    static class FastScanner {
        BufferedReader br;
        StringTokenizer stok;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String next() throws IOException {
            while (stok == null || !stok.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return null;
                }
                stok = new StringTokenizer(s);
            }
            return stok.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        char nextChar() throws IOException {
            return (char) (br.read());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }
    }
}
