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

public class D {

	static FasterScanner sc = new FasterScanner();
	static PrintWriter out = new PrintWriter(System.out);

	static void exit() {
		out.close();
	}

	public D () {
		int n = sc.nextInt();
		long [] A = new long [n];
		int len = 0;
		for (int i = 0;i < n; i++) {
			long next = sc.nextLong();
			if (next > 0) A[len++] = next;
		}
		int [] col = new int [64];
		for (int i = 1; i <= 64; i++) {
			for (int j = 0; j < len; j++) {
				long e = A[j];
				if ((e & (1L << (i-1))) > 0) {
//					out.println("============" + i + ":" + e);
					col[i] ++;
					if (col[i] >= 3) {
//						out.println("shortest cycle found: " + i);
						out.println(3);
						return;
					}
				}
			}
		}
		
		// at most 128 nodes
		int [][] graph = new int [len][len];
		for (int i = 0; i < len; i++) {
			for (int j = i+1; j < len; j++) {
				if ((A[i] & A[j]) > 0) graph[i][j] = graph[j][i] = 1;
			}
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < len; i++) {
			int cur_len = bfs(graph, i, len);
			min = Math.min(min, cur_len);
		}
		if (min == Integer.MAX_VALUE) out.println(-1);
		else out.println(min);
	}

	int bfs(int [][] graph, int root, int n) {
		Queue<Integer> q = new LinkedList<>();
		int [] dist = new int [n];
		int [] par = new int [n];
		Arrays.fill(dist, -1);
		Arrays.fill(par, -1);
		int min_dist = Integer.MAX_VALUE;
		
		q.add(root);
		dist[root] = 0;
		while (!q.isEmpty()) {
			int cur = q.poll();
			int len = dist[cur];
			for (int i = 0; i < n; i++) {
				if (graph[cur][i] == 1) {
					if (len > 1 && i == root) {
						min_dist = Math.min(min_dist, len + 1);
					}
					if (dist[i] < 0) {
						dist[i] = len+1;
						q.add(i);
						par[i] = cur;
					} else if (par[cur] != i) {
						min_dist = Math.min(min_dist, len + 1 + dist[i]);
					}
				}
			}
		}
		return min_dist;
	}

	public static void main(String[] args) {
		new D();
		exit();
	}

	static class FasterScanner {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int snumChars;

        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = System.in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n, int f) {
            if (f == 0) {
                int[] arr = new int[n];
                for (int i = 0; i < n; i++) {
                    arr[i] = nextInt();
                }
                return arr;
            } else {
                int[] arr = new int[n + 1];
                for (int i = 1; i < n + 1; i++) {
                    arr[i] = nextInt();
                }
                return arr;
            }
        }

        public long[] nextLongArray(int n, int f) {
            if (f == 0) {
                long[] arr = new long[n];
                for (int i = 0; i < n; i++) {
                    arr[i] = nextLong();
                }
                return arr;
            } else {
                long[] arr = new long[n + 1];
                for (int i = 1; i < n + 1; i++) {
                    arr[i] = nextLong();
                }
                return arr;
            }
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
}