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.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		long[] arr=new long[n];
		
		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextLong();
		}
		
		ArrayList<Integer>[] brr=new ArrayList[n+1];
		HashMap<String,Integer> map=new HashMap<>();
		
		for(int i=0;i<n+1;i++)
		{
			ArrayList<Integer> list=new ArrayList<>();
			brr[i]=list;
		}
		
		int p=0;
		
		for(int i=0;i<61;i++)
		{
			int count=0;
			
			ArrayList<Integer> list=new ArrayList<>();
			
			for(int j=0;j<n;j++)
			{
				if((arr[j]&(1l<<i))>0)
				{
					count++;
					list.add(j+1);
				}
			}
			
			if(count>2)
			{
				p=1;
				break;
			}
			else if(count==2)
			{	
				int key1=list.get(0);
				int key2=list.get(1);
				
				if(!map.containsKey(key1+" "+key2)&&!map.containsKey(key2+" "+key1))
				{
					brr[list.get(0)].add(list.get(1));
					brr[list.get(1)].add(list.get(0));
					
					map.put(key1+" "+key2,1);
					map.put(key2+" "+key1,1);
				}
			}
		}
		
		if(p==1)
		{
			System.out.println(3);
		}
		else
		{	
			int min=Integer.MAX_VALUE;
			
			for(int i=1;i<n+1;i++)
			{
				for(int j=0;j<brr[i].size();j++)
				{
					int ans=bfs(brr,i,brr[i].get(j));
					
					if(ans!=-1&&ans<min)
					{
						min=ans;
					}
				}
			}
			
			if(min==Integer.MAX_VALUE)
				System.out.println(-1);
			else
				System.out.println(min);
		}	
	}
	
	public static int bfs(ArrayList<Integer>[] brr,int start,int end)
	{
		Queue<pair> q=new LinkedList<>();
		HashMap<Integer,Integer> map=new HashMap<>();
		
		pair p=new pair(start,0);
		q.add(p);
		map.put(start,1);
		
		int ans=-1;
		
		while(!q.isEmpty())
		{
			pair curr=q.poll();
			
			if(curr.val==end)
			{
				ans=curr.dis+1;
				break;
			}
			
			if(curr.val==start)
			{
				for(int i=0;i<brr[curr.val].size();i++)
				{
					int now=brr[curr.val].get(i);
					
					if(now!=end&&!map.containsKey(now))
					{
						pair pp=new pair(now,curr.dis+1);
						q.add(pp);
						map.put(now,1);
					}
					
				}
			}
			else
			{
				for(int i=0;i<brr[curr.val].size();i++)
				{
					int now=brr[curr.val].get(i);
					
					if(!map.containsKey(now))
					{
						pair pp=new pair(now,curr.dis+1);
						q.add(pp);
						map.put(now,1);
					}
					
				}
			}
		}
		
		return ans;
		
	}
	
}

class pair
{
	int val;
	int dis;
	
	public pair(int val,int dis)
	{
		this.val=val;
		this.dis=dis;
	}
}