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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.StringTokenizer;
 
public class ProblemD {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		
		long[] arr = new long[n];
		ArrayList<Integer>[] adj = new ArrayList[65];
		
		for(int i=0;i<=64;i++)
			adj[i] = new ArrayList<>();
		
		boolean threeCycle = false;
		for(int i=0;i<n;i++)
		{
			arr[i]= s.nextLong();
			long num = arr[i];
			
			int bit = 0;
			while(num !=0)
			{
				long mod = num%2;
				if(mod==1)
					adj[bit].add(i);
				
				if(adj[bit].size()>=3)
					threeCycle = true;
				
				num = num>>1;
				bit++;
			}
		}
		
		if(threeCycle)
		{
			System.out.println(3);
			System.exit(0);
		}
		
		ArrayList<Integer>[] aj = new ArrayList[n];
		
		for(int i=0;i<n;i++)
			aj[i] = new ArrayList<>();
		
		for(int i=0;i<=64;i++)
		{
			if(adj[i].size()==0||adj[i].size()==1)
				continue;
			int x = adj[i].get(0);
			int y = adj[i].get(1);
			
			aj[x].add(y);
			aj[y].add(x);
		}
		
		boolean[] done = new boolean[n];
		int ans = -1;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<aj[i].size();j++)
			{
				int cyc = getShortestCycle(i, aj[i].get(j), aj);
				
				if(cyc != -1)
				{
					if(ans == -1 || ans > cyc)
						ans = cyc;
				}
			}
		}
		
		System.out.println(ans);
		
 
	}
	
	public static int getShortestCycle(int src, int dest, ArrayList<Integer>[] adj)
	{
		Queue<Integer> q1 = new LinkedList<>();
		Queue<Integer> q2 = new LinkedList<>();
		
		boolean[] done = new boolean[adj.length];
		q1.add(src);
		q2.add(1);
		
		done[src] = true;
		
		while(!q1.isEmpty())
		{
			int x = q1.remove();
			int dist = q2.remove();
			
			if(x == dest)
				return dist;
			
			for(int i=0;i<adj[x].size();i++)
			{
				if((x==src && adj[x].get(i)==dest)||done[adj[x].get(i)])
					continue;
				else
				{
					q1.add(adj[x].get(i));
					q2.add(dist+1);
					done[adj[x].get(i)] = true;
				}
			}
		}
		return -1;
	}
 
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            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; 
        } 
    } 
}