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.util.*;
 
public class Codeforces1205B {
 
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int ctr = 0;
		long[] a = new long[n];
		
		st = new StringTokenizer(br.readLine());
		
		for (int i = 0; i < n; i++) {
			long x = Long.parseLong(st.nextToken());
			if (x != 0) {
				a[ctr] = x;
				ctr++;
			}
		}
		n = ctr;
		
		if (n > 120) {
			//there is some bit which is covered by at least 3 things
			System.out.println(3);
		}
		else {
			//create adjacency list
			int[] ctrs = new int[n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if ((i != j) && ((a[i]&a[j]) > 0)) {
						ctrs[i]++;
					}
				}
			}
			int[][] adjacency = new int[n][];
			for (int i = 0; i < n; i++) {
				adjacency[i] = new int[ctrs[i]];
				ctrs[i] = 0;
				for (int j = 0; j < n; j++) {
					if ((i != j) && ((a[i]&a[j]) > 0)) {
						adjacency[i][ctrs[i]] = j;
						ctrs[i]++;
					}
				}
			}
						
			//for (int i = 0; i < n; i++) {
			//	for (int j = 0; j < ctrs[i]; j++) {
			//		System.out.print(adjacency[i][j] + " ");
			//	}
			//	System.out.println();
			//}
			
			//BFS time
			int min = n+1;
			for (int index = 0; index < n; index++) {
				//run BFS from vertex index
				boolean[] found = BFSsearch(adjacency, n, index);
				int[] parent = BFSparentTree(adjacency, n, index);
				int[] path = BFSpath(adjacency, n, index);
				
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < n; j++) {
						if ((i != j) && ((a[i]&a[j]) > 0)) {
							if (((i != parent[j]) && (j != parent[i])) && (found[i])) {
								min = Math.min(min, path[i]+path[j]+1);
							}
						}
					}
				}
				
			}
			if (min == (n+1)) {
				System.out.println(-1);
			}
			else {
				System.out.println(min);
			}
		}
		
		pw.close();
	}
	
	public static boolean[] BFSsearch (int[][] adjacency, int v, int index) {
		boolean[] found = new boolean[v];
		found[index] = true;
		int[] indexList = new int[v];
		int start = 0;
		int end = 1;
		indexList[0] = index;
		while ((end < v) && (start < end)) {
			for (int i = 0; i < adjacency[indexList[start]].length; i++) {
				if (found[adjacency[indexList[start]][i]] == false) {
					found[adjacency[indexList[start]][i]] = true;
					indexList[end] = adjacency[indexList[start]][i];
					end++;
				}
			}
			start++;
		}
		return found;
	}
	
	public static int[] BFSpath (int[][] adjacency, int v, int index) {
		boolean[] found = new boolean[v];
		found[index] = true;
		int[] path = new int[v];
		path[index] = 0;
		int[] indexList = new int[v];
		int start = 0;
		int end = 1;
		indexList[0] = index;
		while ((end < v) && (start < end)) {
			for (int i = 0; i < adjacency[indexList[start]].length; i++) {
				if (found[adjacency[indexList[start]][i]] == false) {
					found[adjacency[indexList[start]][i]] = true;
					indexList[end] = adjacency[indexList[start]][i];
					path[adjacency[indexList[start]][i]] = path[indexList[start]]+1;
					end++;
				}
			}
			start++;
		}
		return path;
	}
	
	public static int[] BFSparentTree(int[][] adjacency, int v, int index) {
		boolean[] found = new boolean[v];
		found[index] = true;
		int[] indexList = new int[v];
		int[] parent = new int[v];
		int start = 0;
		int end = 1;
		indexList[0] = index;
		parent[index] = index;
		while ((end < v) && (start < end)) {
			for (int i = 0; i < adjacency[indexList[start]].length; i++) {
				if (found[adjacency[indexList[start]][i]] == false) {
					found[adjacency[indexList[start]][i]] = true;
					indexList[end] = adjacency[indexList[start]][i];
					parent[adjacency[indexList[start]][i]] = indexList[start];
					end++;
				}
			}
			start++;
		}
		return parent;
		
	}
	
}