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.
// practice with rainboy
import java.io.*;
import java.util.*;

public class CF1206D extends PrintWriter {
	CF1206D() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1206D o = new CF1206D(); o.main(); o.flush();
	}

	int[] next, jj; int l_ = 1;
	int link(int l, int j) { next[l_] = l; jj[l_] = j; return l_++; }
	int[] ao, dd, qq;
	static class E {
		int i, j;
		E(int i, int j) {
			this.i = i; this.j = j;
		}
	}
	E[] ee;
	void init(int n, int m) {
		next = new int[1 + m * 2];
		jj = new int[1 + m * 2];
		ao = new int[n];
		dd = new int[n]; Arrays.fill(dd, n);
		ee = new E[m];
		qq = new int[m];
	}
	int bfs(int n, int s) {
		int ans = n + 1;
		int head = 0, cnt = 0;
		dd[s] = 0;
		qq[head + cnt++] = s;
		while (cnt > 0) {
			int i = qq[head++]; cnt--;
			int d = dd[i];
			if (d + 1 + d >= ans)
				break;
			for (int l = ao[i]; l != 0; l = next[l]) {
				int j = jj[l];
				if (dd[j] == n) {
					dd[j] = d + 1;
					qq[head + cnt++] = j;
				} else if (dd[j] >= d)
					ans = Math.min(ans, d + 1 + dd[j]);
			}
		}
		head += cnt;
		while (head-- > 0)
			dd[qq[head]] = n;
		return ans;
	}
	void main() {
		int n = sc.nextInt();
		long[] aa = new long[n];
		for (int i = 0; i < n; i++)
			aa[i] = sc.nextLong();
		init(n, 64);
		int m = 0;
		for (int b = 0; b < 60; b++) {
			int i1 = -1, i2 = -1;
			for (int i = 0; i < n; i++)
				if ((aa[i] & 1L << b) != 0) {
					if (i1 == -1) {
						i1 = i;
					} else if (i2 == -1) {
						i2 = i;
						ee[m++] = new E(i1, i2);
					} else {
						println(3);
						return;
					}
				}
		}
		Arrays.sort(ee, 0, m, (e, f) -> e.i != f.i ? e.i - f.i : e.j - f.j);
		for (int h = 0; h < m; h++)
			if (h == 0 || ee[h].i != ee[h - 1].i || ee[h].j != ee[h - 1].j) {
				int i = ee[h].i, j = ee[h].j;
				ao[i] = link(ao[i], j);
				ao[j] = link(ao[j], i);
			}
		int ans = n + 1;
		for (int i = 0; i < n; i++)
			ans = Math.min(ans, bfs(n, i));
		println(ans == n + 1 ? -1 : ans);
	}
}
