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 implements Runnable {
	public static void main (String[] args) {new Thread(null, new D(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextLong();
		int[] freq = new int[65];
		for(int i = 0; i < n; i++) {
			long mx = Long.highestOneBit(a[i]);
			for(int j = 0; j < 65; j++) {
				long cur = 1L << j;
				if(cur > mx) break;
				if((cur & a[i]) > 0) freq[j]++;
			}
		}
		for(int j = 0; j < 65; j++) {
			if(freq[j] > 2) {
				System.out.println(3);
				return;
			}
		}
		ArrayList<Long> nums = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			if(a[i] > 0) nums.add(a[i]);
		}
		if(nums.size() > 200) {
			throw new RuntimeException("wtf");
		}
		
		int m = nums.size();
		ArrayList<Integer>[] adj = new ArrayList[m];
		for(int i = 0; i < m; i++) adj[i] = new ArrayList<>();
		for(int i = 0; i < m; i++) {
			for(int j = i+1; j < m; j++) {
				long v1 = nums.get(i);
				long v2 = nums.get(j);
				if((v1&v2) > 0) {
					adj[i].add(j);
					adj[j].add(i);
				}
			}
		}
		
		int res = 100100;
		for(int i = 0; i < adj.length; i++) {
			int[] dist = new int[m];
			int[] par = new int[m];
			Arrays.fill(dist, -1);
			dist[i] = 0;
			ArrayDeque<Integer> dq = new ArrayDeque<>();
			dq.add(i);
			while(!dq.isEmpty()) {
				int u = dq.pollFirst();
				for(int v : adj[u]) {
					if(dist[v] != -1) continue;
					dist[v] = 1+dist[u];
					par[v] = u;
					dq.add(v);
				}
			}
			for(int j = 0; j < m; j++) {
				if(dist[j] == -1) continue;
				for(int k : adj[j]) {
					if(par[k] != j && par[j] != k) {
						res = Math.min(res, 1+dist[j]+dist[k]);
					}
				}
			}
		}
		if(res == 100100) res = -1;
		out.println(res);
		
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}