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.*; 
import java.math.BigInteger;
import java.util.*;
  
public class Main {
	
    static class FastScanner
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() 
        { 
            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; 
        } 
    } 
  
    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner();
        int N = sc.nextInt();
        ArrayList<Long> numsTemp = new ArrayList<Long>(N);
        for (int i = 0; i < N; i++) {
        	long n = sc.nextLong();
        	if (n > 0)
        		numsTemp.add(n);
        }
        N = numsTemp.size();
        if (N < 3) {
        	System.out.println(-1);
        	return;
        }
        long[] nums = new long[N];
        for (int i = 0; i < N; i++)
        	nums[i] = numsTemp.get(i);
        
        int[] rep = new int[60];
        for (int i = 0; i < N; i++) {
        	long num = nums[i];
        	int pow = (int)(Math.log(num)/Math.log(2));
        	while (num > 0) {
        		if (num >= (long)Math.pow(2, pow)) {
        			rep[pow] += 1;
        			num -= (long)Math.pow(2, pow);
        			pow--;
        		} else {
        			rep[pow] += 0;
        			pow--;
        		}
        	}
        }
        for (int pow = 0; pow < 60; pow++) {
        	if (rep[pow] > 2) {
        		System.out.println(3);
        		return;
        	}
        }
        //Else, at this point N must be at most 120.
        int[][] adj = new int[N][N];
        int E = 0;
        int[][] edges = new int[N*N][2];
        for (int i = 0; i < N; i++) {
        	for (int j = i+1; j < N; j++) {
        		long ans = (nums[i] & nums[j]);
        		if (ans > 0) {
        			adj[i][j] = 1;
        			adj[j][i] = 1;
        			edges[E][0] = i;
        			edges[E][1] = j;
        			E++;
        		}
        	}
        }
        
        int best = Integer.MAX_VALUE;
        for (int i = 0; i < E; i++) {
            int s = edges[i][0];
            int e = edges[i][1];
            adj[s][e] = 0;
            adj[e][s] = 0;
            PriorityQueue<int[]> pq = new PriorityQueue<int[]>(new Comparator<int[]>(){
            	public int compare(int[] a, int[] b) {
            		return a[1] - b[1];
                }
            });
            int[] distances = new int[N];
            for (int v = 0; v < N; v++) {
            	distances[v] = Integer.MAX_VALUE;
            }
            distances[s] = 0;

            //Dijkstra's Algorithm
            int[] temp = {s,0};
            pq.add(temp);
            while (! pq.isEmpty()) {
            	temp = pq.poll();
            	int parent = temp[0];
            	for (int child = 0; child < N; child++) {
            		if (adj[parent][child] == 1 && distances[child] > distances[parent] + 1) {
            			distances[child] = distances[parent] + 1;
            			int[] temp2 = {child,distances[child]};
            			pq.add(temp2);
            		}
            	}
            }
            if (distances[e] < Integer.MAX_VALUE) {
            	best = Math.min(best,distances[e]+1);
            }
            adj[s][e] = 1;
            adj[e][s] = 1;
        }
        
        if (best == Integer.MAX_VALUE) {
        	System.out.println(-1);
        } else {
        	System.out.println(best);
        }
    }
}