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 D{
	static List<Long> c;
	static HashSet<Integer>[] adj;
	static boolean[] vis;
	static int max = Integer.MAX_VALUE/3;
	static int root = 0;
	
	
	
	public static void main(String[] args) throws IOException {
		// br = new BufferedReader(new FileReader(".in"));
		// out = new PrintWriter(new FileWriter(".out"));
		//new Thread(null, new (), "peepee", 1<<28).start();
		
		int n =readInt();
		long[] a= new long[n];
		for (int i = 0; i < n; i++) a[i] = readLong();
		List<Integer>[] b = new List[64];
		for (int i = 0 ; i <64; i++) b[i] = new ArrayList<Integer>();
		for (int i =0 ; i < n; i++) {
			for (int j =0; j < 64; j++) {
				long v = a[i]&(1L<<j);
				if (v > 0) b[j].add(i);
			}
			//String s = Long.toBinaryString(a[i]);
			
		}
		
		
		
		boolean works = false;
		for (int i = 0; i < 64; i++) {
			if (b[i].size() >= 3) works = true;
		}
		if (works) {
			out.println(3);
		}
		else {
			// At most 2 unique per category so I think brute force is applicable
			 c = new ArrayList<Long>();
			 HashSet<Integer> hs = new HashSet<Integer>();
			for (int i = 0; i < 64; i++) {
				for (int x: b[i]) hs.add(x);
			}
			for (int x: hs) c.add(a[x]);
			adj = new HashSet[c.size()];
			for (int i = 0; i < adj.length; i++) adj[i] = new HashSet<Integer>();
			for (int i= 0 ; i < adj.length; i++) {
				for (int j = 0; j < adj.length; j++) if ((c.get(j) & c.get(i)) > 0) {
					adj[i].add(j);
					adj[j].add(i);
				}
			}
			vis = new boolean[c.size()];
			int min = Integer.MAX_VALUE/3;
			for (int i = 0; i < c.size(); i++) {
				List<Integer> toQuery = new ArrayList<Integer>(adj[i]);
				for (int x: toQuery) {
					if (x==i)continue;
					adj[i].remove(x);
					adj[x].remove(i);
					
					Arrays.fill(vis, false);
					int[] dist = new int[c.size()];
					max = Integer.MAX_VALUE/3;
					Arrays.fill(dist, Integer.MAX_VALUE/3);
					ArrayDeque<Integer> q = new ArrayDeque<Integer>();
					dist[i] = 0;
					q.add(i);
					while (!q.isEmpty()) {
						int h = q.poll();
						if (vis[h]) continue;
						vis[h] = true;
						for (int x1: adj[h]) {
							if (vis[x1]) continue;
							if (dist[x1] <= dist[h]+1) continue;
							dist[x1] = dist[h]+1;
							q.add(x1);
						}
					}
					
					min = Integer.min(min, dist[x]+1);
					
					adj[i].add(x);
					adj[x].add(i);
				}
			}
			out.println(min>1e6 ? -1:min);
		}
		
		out.close();
	}
	
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	static StringTokenizer st = new StringTokenizer("");
	static String read() throws IOException{return st.hasMoreTokens() ? st.nextToken():(st = new StringTokenizer(br.readLine())).nextToken();}
	static int readInt() throws IOException{return Integer.parseInt(read());}
	static long readLong() throws IOException{return Long.parseLong(read());}
	static double readDouble() throws IOException{return Double.parseDouble(read());}
	
}