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

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] s = br.readLine().split(" ");
		ArrayList<Long> faltu = new ArrayList<Long>();
		ArrayList<Long> ar = new ArrayList<Long>(n);
		HashMap<Long, ArrayList<Long>> adj = new HashMap<Long, ArrayList<Long>>();

		for (int i = 0; i < n; i++) {
			ar.add(Long.parseLong(s[i]));
		}

		HashSet<Long> set = new HashSet<Long>(ar);

		if (set.size() > 128) {
			System.out.println(3);
			System.exit(0);
		}

		for (int i = 0; i < 61; i++) {
			faltu.clear();
			for (int j = 0; j < n; j++) {
				if ((ar.get(j) & (1l << i)) != 0) {
					faltu.add(ar.get(j));

				}
			}

			if (faltu.size() >= 3) {
				System.out.println(3);
				System.exit(0);
			}
			if (faltu.size() == 2) {
				if (adj.containsKey(faltu.get(0))) {
					if (!adj.get(faltu.get(0)).contains(faltu.get(1))) {
						adj.get(faltu.get(0)).add(faltu.get(1));
					}
				} else {
					ArrayList<Long> ar1 = new ArrayList<Long>();
					ar1.add(faltu.get(1));
					adj.put(faltu.get(0), ar1);
				}
				if (adj.containsKey(faltu.get(1))) {
					if(!adj.get(faltu.get(1)).contains(faltu.get(0))) {
					adj.get(faltu.get(1)).add(faltu.get(0));}
				} else {
					ArrayList<Long> ar2 = new ArrayList<Long>();
					ar2.add(faltu.get(0));
					adj.put(faltu.get(1), ar2);
				}
			}
		}
		//System.out.println(adj);
		
		ArrayList<Long> current = new ArrayList<Long>();
		ArrayList<Long> next = new ArrayList<Long>();
		HashMap<Long , Integer> level = new HashMap<Long , Integer>();
		int l, min = -1;
		
		for(long i : adj.keySet()) {
			for(long j : adj.get(i)) {
				//run bfs from i for edge i-j while ignoring edge i-j
				l = 0;
				current.clear();
				level.clear();
				next.clear();
				level.put(i, l);
				l++;
				for(int k = 0; k < adj.get(i).size(); k++) {
					if(adj.get(i).get(k).compareTo(j) != 0) {
						current.add(adj.get(i).get(k));
					}
				}
				while(current.size() != 0) {
					for(long k : current) {
						//check if reached j
						if(k == j) {
							if(min < 0) {
								min = l + 1;
							}else {
								min = min > l + 1 ? l + 1 : min;
							}
							next.clear();
							break;
						}
						
						//put in level if not already, add edges to next
						if(!level.containsKey(k)) {
							level.put(k , l);
							next.addAll(adj.get(k));
						}
						
					}
					
					current.clear();
					for(int k = 0; k < next.size(); k++) {
						current.add(next.get(k));
					}
					l++;
					next.clear();
				}
			}
		}
		
		System.out.println(min);

	}
}