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.
# Author : nitish420 --------------------------------------------------------------------
import os
import sys
from io import BytesIO, IOBase

from collections import  deque

def main():
	n=int(input())
	
	arr=[i for i in map(int,input().split()) if i]
	n=len(arr)
	
	if n>120:
		print(3)
		exit()


	graph=[0]*60


	for i in arr:
		j=0
		while i:
			graph[j]+=i&1
			i>>=1
			j+=1
	if max(graph)>=3:
		print(3)
		exit()
	
	final=[[] for _ in range(n)]

	for i in range(n):
		for j in range(i+1,n):
			if arr[i]&arr[j]:
				final[i].append(j)
				final[j].append(i)
	
	ans=300

	for i in range(n):
		dist=[300]*n
		parent=[-1]*n
		q=deque([i])
		dist[i]=0

		while q:
			z=q.popleft()
			for child in final[z]:
				if dist[child]==300:
					dist[child]=dist[z]+1
					parent[child]=z
					q.append(child)
				elif parent[z]!=child and parent[child]!=z:
					ans=min(ans,dist[z]+dist[child]+1)
	

	if ans==300:
		print(-1)
	else:
		print(ans)


#----------------------------------------------------------------------------------------


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda: self.buffer.read().decode('ascii')
		self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')


# endregion

if __name__ == '__main__':
	main()