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.FileInputStream;
        import java.io.IOException;
        import java.io.InputStream;
        import java.io.PrintWriter;
        import java.util.Arrays;
    import java.util.HashMap;
    import java.util.HashSet;
    import java.util.InputMismatchException;
    import java.util.LinkedList;
    import java.util.Queue;
         
        public class d_asf
        {
         
        	InputStream is;
        	PrintWriter out;
        	int n;
        	long a[];
        	private boolean oj = true;
        	class Pair{
        		long a;
        		long b;
        		Pair(long aa,long bb){
        			a=aa;
        			b=bb;
        		}
        	}
        	void solve()
        	{
        		int n=ni();
        		long arr[] = new long[n];
        		for(int i=0;i<n;i++)
        			arr[i]=nl();
        		int bits[] = new int[61];
        		for(int i=0;i<n;i++) {
        			String s = Long.toBinaryString(arr[i]);
        			//tr(s);
        			for(int j=0;j<s.length();j++) {
        				if(s.charAt(j)=='1') {
        					bits[s.length()-j-1]++;
        				}
        			}
        		}
        		//tr(bits);
        		boolean flag=false;
        		for(int i=0;i<61;i++) {
        			if(bits[i]>=3) {
        				flag=true;
        			}
        		}
        		if(flag) {
        			out.println("3");
        		}
        		else {
        			HashMap<Long,HashSet<Long>> hm = new HashMap<>();
        			HashSet<Pair> edges = new HashSet<>();
        			//tr(arr);
        			for(int i=0;i<n;i++) {
        				if(arr[i]==0)
        					continue;
        				for(int j=i+1;j<n;j++) {
        					if((arr[i]&arr[j])!=0&&arr[i]!=arr[j] ) {
        						tr(arr[i],arr[j]);
        						edges.add(new Pair(arr[i], arr[j]));
        						//edges.put(arr[], value)
        						if(hm.containsKey(arr[i])) {
        							hm.get(arr[i]).add(arr[j]);
        						}
        						else {
        							hm.put(arr[i], new HashSet<>());
        							hm.get(arr[i]).add(arr[j]);
        						}
        						if(hm.containsKey(arr[j])) {
        							hm.get(arr[j]).add(arr[i]);
        						}
        						else {
        							hm.put(arr[j], new HashSet<>());
        							hm.get(arr[j]).add(arr[i]);
        						}
        					}
        					
        				}
        			}
        			//out.println(hm);
        // 			if(n==10000) {
        // 				out.println(hm);
        // 			}
        			long min =Long.MAX_VALUE;
        		//	out.println(edges);
        			for(Pair edge : edges) {
        				long u = edge.a;
        				long v = edge.b;
        				hm.get(u).remove(v);
        				hm.get(v).remove(u);
        				HashMap<Long,Long> level = new HashMap<>();
        				HashSet<Long> visited = new HashSet<>();
        				bfs(hm,visited,level,u);
        				hm.get(u).add(v);
        				hm.get(v).add(u);
        				if(level.containsKey(v)) {
        					min=Math.min(min, level.get(v));
        				}    					
        			}
        			if(min!=Long.MAX_VALUE)
        			out.println(min);
        			else
        				out.println(-1);
        			
        		}
        	}
        	void bfs(HashMap<Long,HashSet<Long>> G,HashSet<Long> visited,HashMap<Long,Long> level,long u) {
        		Queue<Long> Q = new LinkedList<>();
        		Q.add(u);
        		level.put(u, 1L);
        		while(!Q.isEmpty()) {
        			long temp = Q.poll();
        			visited.add(temp);
        			for(long val : G.get(temp)) {
        				if(!visited.contains(val)) {
        					Q.add(val);
        					level.put(val,level.get(temp)+1);
        				}
        			}
        		}
        	}
        
        	void run() throws Exception
        	{
        		String INPUT = "C:\\Users\\Admin\\Desktop\\input.txt";
        		is = oj ? System.in : new FileInputStream(INPUT);
        		out = new PrintWriter(System.out);
         
        		long s = System.currentTimeMillis();
        		solve();
        		out.flush();
        		tr(System.currentTimeMillis() - s + "ms");
        	}
         
        	public static void main(String[] args) throws Exception
        	{
        		new Thread(null, new Runnable()
        		{
        			public void run()
        			{
        				try
        				{
        					new d_asf().run();
        				} catch (Exception e)
        				{
        					e.printStackTrace();
        				}
        			}
        		}, "1", 1 << 26).start();
        	}
         
        	private byte[] inbuf = new byte[1024];
        	public int lenbuf = 0, ptrbuf = 0;
         
        	private int readByte()
        	{
        		if (lenbuf == -1)
        			throw new InputMismatchException();
        		if (ptrbuf >= lenbuf)
        		{
        			ptrbuf = 0;
        			try
        			{
        				lenbuf = is.read(inbuf);
        			} catch (IOException e)
        			{
        				throw new InputMismatchException();
        			}
        			if (lenbuf <= 0)
        				return -1;
        		}
        		return inbuf[ptrbuf++];
        	}
         
        	private boolean isSpaceChar(int c)
        	{
        		return !(c >= 33 && c <= 126);
        	}
         
        	private int skip()
        	{
        		int b;
        		while ((b = readByte()) != -1 && isSpaceChar(b))
        			;
        		return b;
        	}
         
        	private double nd()
        	{
        		return Double.parseDouble(ns());
        	}
         
        	private char nc()
        	{
        		return (char) skip();
        	}
         
        	private String ns()
        	{
        		int b = skip();
        		StringBuilder sb = new StringBuilder();
        		while (!(isSpaceChar(b)))
        		{ // when nextLine, (isSpaceChar(b) && b != ' ')
        			sb.appendCodePoint(b);
        			b = readByte();
        		}
        		return sb.toString();
        	}
         
        	private char[] ns(int n)
        	{
        		char[] buf = new char[n];
        		int b = skip(), p = 0;
        		while (p < n && !(isSpaceChar(b)))
        		{
        			buf[p++] = (char) b;
        			b = readByte();
        		}
        		return n == p ? buf : Arrays.copyOf(buf, p);
        	}
         
        	private char[][] nm(int n, int m)
        	{
        		char[][] map = new char[n][];
        		for (int i = 0; i < n; i++)
        			map[i] = ns(m);
        		return map;
        	}
         
        	private int[] na(int n)
        	{
        		int[] a = new int[n];
        		for (int i = 0; i < n; i++)
        			a[i] = ni();
        		return a;
        	}
         
        	private int ni()
        	{
        		int num = 0, b;
        		boolean minus = false;
        		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
        			;
        		if (b == '-')
        		{
        			minus = true;
        			b = readByte();
        		}
         
        		while (true)
        		{
        			if (b >= '0' && b <= '9')
        			{
        				num = num * 10 + (b - '0');
        			} else
        			{
        				return minus ? -num : num;
        			}
        			b = readByte();
        		}
        	}
         
        	private long nl()
        	{
        		long num = 0;
        		int b;
        		boolean minus = false;
        		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
        			;
        		if (b == '-')
        		{
        			minus = true;
        			b = readByte();
        		}
         
        		while (true)
        		{
        			if (b >= '0' && b <= '9')
        			{
        				num = num * 10 + (b - '0');
        			} else
        			{
        				return minus ? -num : num;
        			}
        			b = readByte();
        		}
        	}
         
        	private void tr(Object... o)
        	{
        		if (!oj)
        			System.out.println(Arrays.deepToString(o));
        	}
         
        }