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.
/*	/ ﾌﾌ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ム
	/ )\⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀  Y
	(⠀⠀| ( ͡° ͜ʖ ͡°）⠀⌒(⠀ ノ
	(⠀ ﾉ⌒ Y ⌒ヽ-く __／
	| _⠀｡ノ| ノ｡ |/
	(⠀ー '_人`ー ﾉ
	⠀|\ ￣ _人'彡ﾉ
	⠀ )\⠀⠀ ｡⠀⠀ /
	⠀⠀(\⠀ #⠀ /
	⠀/⠀⠀⠀/ὣ====================D-
	/⠀⠀⠀/⠀ \ \⠀⠀\
	( (⠀)⠀⠀⠀⠀ ) ).⠀)
	(⠀⠀)⠀⠀⠀⠀⠀( | /
	|⠀ /⠀⠀⠀⠀⠀⠀ | /
	[_] ⠀⠀⠀⠀⠀[___]                     */
// Main Code at the Bottom
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	//Fast IO class
    static class FastReader {
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader() {
        	boolean env=System.getProperty("ONLINE_JUDGE") != null;
        	if(!env) {
        		try {
					br=new BufferedReader(new FileReader("src\\input.txt"));
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				}
        	}
        	else 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(); 
        } 
        int nextInt() {
            return Integer.parseInt(next()); 
        } 
        long nextLong() {
            return Long.parseLong(next()); 
        } 
        double nextDouble() {
            return Double.parseDouble(next()); 
        } 
        String nextLine() {
            String str = ""; 
            try {
                str = br.readLine(); 
            } 
            catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }     
    static long MOD=1000000000+7;
    //Euclidean Algorithm
    static long gcd(long A,long B){
        if(B==0) return A;
        return gcd(B,A%B);
    }
    //Modular Exponentiation
    static long fastExpo(long x,long n){
        if(n==0) return 1;
        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
    }
    //Prime Number Algorithm
    static boolean isPrime(long n){
        if(n<=1) return false;
        if(n<=3) return true;
        if(n%2==0 || n%3==0) return false;
        for(int i=5;i*i<=n;i+=6) if(n%i==0 || n%(i+2)==0) return false;
        return true;
    }
    //Reverse an array
    static <T> void reverse(T arr[],int l,int r){
    	Collections.reverse(Arrays.asList(arr).subList(l, r));
    }
    //Print array
    static <T> void print1d(T arr[]) {
    	out.println(Arrays.toString(arr));
    }
    static <T> void print2d(T arr[][]) {
    	for(T a[]: arr) out.println(Arrays.toString(a));
    }
    // Pair
    static class pair{
    	long x,y;
    	pair(long a,long b){
    		this.x=a;
    		this.y=b;
    	}
    	public boolean equals(Object obj) {
    		if(obj == null || obj.getClass()!= this.getClass()) return false;
            pair p = (pair) obj;
            return (this.x==p.x && this.y==p.y);
        }
    	public int hashCode() {
            return Objects.hash(x,y);
        }
    }
    static FastReader sc=new FastReader();
    static PrintWriter out=new PrintWriter(System.out);
    //Main function(The main code starts from here) 
    static int V;
    static ArrayList<Integer> graph[];
    static void init(int n){
        V=n;
        graph=new ArrayList[V];
        for(int i=0;i<V;i++) graph[i]=new ArrayList<>();
    }
    static void addEdge(int src,int dest){
        graph[src].add(dest);
        graph[dest].add(src);
    }
    static int bfs(int s,int d) {
    	int cost=0;
    	int visited[]=new int[V];
    	Queue<Integer> q=new LinkedList<>();
    	q.add(s);
    	q.add(-1);
    	while(!q.isEmpty()) {
    		s=q.poll();
    		if(s==-1) {
    			cost++;
    			q.add(-1);
    			if(q.peek()==-1) break;
    			else continue;
    		}
    		if(s==d) return cost;
    		if(visited[s]==1) continue;
    		visited[s]=1;
    		for(Integer x: graph[s]) q.add(x);
    	}
    	return Integer.MAX_VALUE;
    }
    public static void main (String[] args) throws java.lang.Exception {
    	int test=1;
        while(test-->0) {
        	MOD=998244353;
        	int n=sc.nextInt(),flag=0;
        	HashSet<pair> edges=new HashSet<>();
        	HashMap<pair,Integer> map=new HashMap<>();
        	init(n);
        	long a[]=new long[n];
        	for(int i=0;i<n;i++) a[i]=sc.nextLong();
        	for(long bit=0L;bit<=60L;bit++) {
        		ArrayList<Integer> tmp=new ArrayList<>();
        		for(int i=0;i<n;i++) if((1L&(a[i]>>bit))==1L) tmp.add(i);
        		if(tmp.size()>=3) {
        			flag=1;
        			break;
        		}
        		else if(tmp.size()==2) {
        			if(map.get(new pair(tmp.get(0),tmp.get(1)))==null && map.get(new pair(tmp.get(1),tmp.get(0)))==null) {
        				addEdge(tmp.get(0),tmp.get(1));
        				map.put(new pair(tmp.get(0),tmp.get(1)), 1);
        			}	
        			edges.add(new pair(tmp.get(0),tmp.get(1)));
        		}
        	}
        	if(flag==1) {
        		out.println(3);
        		break;
        	}
        	int min=Integer.MAX_VALUE;
        	//for(pair p: edges) System.out.println(p.x+" "+p.y);
        	for(pair p: edges) {
        		graph[(int)p.x].remove(new Integer((int) p.y));
        		graph[(int)p.y].remove(new Integer((int)(p.x)));
        		min=Math.min(min, bfs((int)p.x,(int)p.y));
        		//out.println(min+" "+p.x+" "+p.y);
        		graph[(int)p.x].add((int)(p.y));
        		graph[(int)p.y].add((int)(p.x));
        	}
        	if(min==Integer.MAX_VALUE) out.println(-1);
        	else out.println(min+1);
        }
        out.flush();
        out.close();
    }
}