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.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
public class Solution{ 
    static InputReader sc;
    static PrintWriter wc;
    static class Pair{
        int x,y;
        Pair(int x,int y){
            this.x=x;
            this.y=y;
        }
    }
    public static void main(String[] args) {
        sc = new InputReader(System.in);
        wc = new PrintWriter(System.out);
        int n=sc.nextInt(),i,j;
        long temp,inp;
        HashSet<Long> set=new HashSet<>();
        long arr[]=new long[n];
        ArrayList<Integer> bits[]=new ArrayList[60];
        for(i=0;i<60;i++) bits[i]=new ArrayList<>();
        for(i=0;i<n;i++){
            inp=sc.nextLong();
            arr[i]=inp;
            temp=1;
            j=0;
            if((temp&inp)==temp){
                bits[j].add(i);
                //wc.println(temp+" "+inp);
            }
            for(j=1;j<60;j++){
                temp=temp<<1;
                //wc.println(temp);
                if((temp&inp)==temp){
                    bits[j].add(i);
                    //wc.println(temp+" "+inp);
                }
            }
        }
        ArrayList<Integer> graph[]=new ArrayList[n];
        for(i=0;i<n;i++){
            graph[i]=new ArrayList<>();
        }
        for(i=0;i<60;i++){
            if(bits[i].size()>2){
                //System.out.println(i);
                wc.println(3);
                wc.close();
                return;
            }
            else if(bits[i].size()==2){
                graph[bits[i].get(0)].add(bits[i].get(1));
                graph[bits[i].get(1)].add(bits[i].get(0));
            }
        }
        int min=Integer.MAX_VALUE;
        for(i=0;i<60;i++){
            if(bits[i].size()<2) continue;
            Queue<Pair> q=new LinkedList<Pair>();
            q.add(new Pair(bits[i].get(0),1));
            int[] visited=new int[n];
            visited[bits[i].get(0)]=1;
            ArrayList<Pair> path=new ArrayList<>();
            while(!q.isEmpty()){
                Pair p=q.remove();
                path.add(p);
                if(p.x==bits[i].get(1)){
                    min=Math.min(min,p.y);
                    if(p.y==2){
                        for(Pair p1:path){
                            wc.println(p1.x+" "+p1.y);
                        }
                    }
                    break;
                }
                for(Integer next:graph[p.x]){
                    if(bits[i].get(0)==p.x&&next.equals(bits[i].get(1))) continue;
                    if(visited[next]==0){
                        visited[next]=1;
                        q.add(new Pair(next,p.y+1));
                    }
                }
            }
            if(min==2){
                //for(Long a:path) wc.print(a+" ");
                //wc.println();
            }
        }
        wc.println(min==Integer.MAX_VALUE?-1:min);
        wc.close();
    }
    static class InputReader {
        
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }
        
        public int read()
        {
            if (numChars==-1) 
                throw new InputMismatchException();
            if (curChar >= numChars)
            {
                curChar = 0;
                try 
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                
                if(numChars <= 0)               
                    return -1;
            }
            return buf[curChar++];
        }
     
        public String nextLine()
        {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt()
        {
            int c = read();
            
            while(isSpaceChar(c)) 
                c = read();
            
            int sgn = 1;
            
            if (c == '-') 
            {
                sgn = -1;
                c = read();
            }
            
            int res = 0;
            do 
            {
                if(c<'0'||c>'9') 
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c)); 
            
            return res * sgn;
        }
        
        public long nextLong() 
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') 
            {
                sgn = -1;
                c = read();
            }
            long res = 0;
            
            do 
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
                return res * sgn;
        }
        
        public double nextDouble() 
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') 
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') 
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') 
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) 
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        
        public String readString() 
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do 
            {
                res.appendCodePoint(c);
                c = read();
            } 
            while (!isSpaceChar(c));
            
            return res.toString();
        }
     
        public boolean isSpaceChar(int c) 
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
     
        public String next() 
        {
            return readString();
        }
        
        public interface SpaceCharFilter 
        {
            public boolean isSpaceChar(int ch);
        }
    }   
}