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.*;
import java.math.*;

public class D {

	public class Node {
		public int id;
		public ArrayList<Node> children;

		public Node(int id) {
			this.id = id;
			children = new ArrayList<Node>();

		}

	}

	public class Pair {
		public int id;
		public int depth;

		public Pair(int id, int depth) {
			this.id = id;
			this.depth = depth;
		}
	}


	public void realMain() throws Exception {

		BufferedReader fin = new BufferedReader(new InputStreamReader(System.in), 1000000);

		String in = fin.readLine();

		String[] ar = in.split(" ");

		int n = Integer.parseInt(ar[0]);
		
		long[] a = new long[n];
		int cnt = 0;

		for(int i = 0; i < n; i++) {
			long ret = 0;
			boolean dig = false;
			for (int ch = 0; (ch = fin.read()) != -1; ) {
        			if (ch >= '0' && ch <= '9') {
            				dig = true;
           				ret = ret * 10 + ch - '0';
        			} else if (dig) break;
    			}

			if(ret != 0) {
				a[cnt] = ret;
				cnt++;
			}
			
		}

		if(cnt > 160) {
			System.out.println("3");
			return;
		}

		n = Math.min(160, cnt);

		ArrayList<Node> nodes = new ArrayList<Node>();
		//int cnt = 0;
		for(int i = 0; i < n; i++) {
			//if(a[i] != 0) {
				Node node = new Node(i);
				nodes.add(node);
			//	cnt++;
			//}
		}

		n = Math.min(n, cnt);

		

		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				//System.out.println( (a[i] & a[j]) );
				if( (a[i] & a[j]) != (long)0 ) {
					nodes.get(i).children.add(nodes.get(j));
					nodes.get(j).children.add(nodes.get(i));
					//System.out.println("link between " + i + " " + j);
				}
			}
		}

		
		int mincycle = Integer.MAX_VALUE;

		for(int i = 0; i < n; i++) {
			boolean[] visited = new boolean[n];
			ArrayList<Pair> toVisit = new ArrayList<Pair>();
			Pair p1 = new Pair(i, 0);
			toVisit.add(p1);
			//System.out.println("----- i: " + i);

			while(toVisit.size() > 0) {
				Pair p = toVisit.remove(0);
				//System.out.println("visiting " + p.id + " with depth " + p.depth);
				if( visited[p.id] ) {
					//if(p.depth > 2) {
					//	mincycle = Math.min(mincycle, p.depth);
					//}
				} else {
					visited[p.id] = true;
					for(int j = 0; j < nodes.get(p.id).children.size(); j++) {
						if(!visited[nodes.get(p.id).children.get(j).id]) {
							Pair pnew = new Pair(nodes.get(p.id).children.get(j).id, p.depth + 1);
							toVisit.add(0, pnew);
						}
						if(nodes.get(p.id).children.get(j).id == i) {
							if(p.depth > 1) {
								mincycle = Math.min(mincycle, p.depth + 1);
							}
						}
					}
				}
			}
		}

		if(mincycle == Integer.MAX_VALUE) {
			System.out.println(-1);
		} else {
			System.out.println(mincycle);
		}
				
			



	}


	public static void main(String[] args) throws Exception {
		D d = new D();
		d.realMain();
	}
}