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.
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
 
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")
 
# ------------------- fast io --------------------
from sys import maxsize as INT_MAX 
from collections import defaultdict,deque
def shortest_cycle(n: int) -> int: 
    ans = INT_MAX 
    for i in range(n): 
        dist=defaultdict(lambda: -1);par=defaultdict(lambda: -1);dist[i]=0
        q = deque([]) ;q.append(i) 
        while q: 
            x=q[0];q.popleft() 
            for child in graph[x]: 
                if dist[child] == -1: 
                    dist[child]=1+dist[x];par[child]=x;q.append(child) 
                elif par[x]!= child and par[child]!= x: 
                    ans=min(ans,dist[x]+dist[child] + 1) 
    if ans==INT_MAX: 
        return -1
    else: 
        return ans 
n=int(input());vals=list(map(int,input().split()));zer=0
for s in range(n):
    if vals[s]==0:
        zer+=1
if n-zer>=121:
    print(3)
else:
    bit=[[] for s in range(60)];info=defaultdict(list)
    for s in range(n):
        num=vals[s]
        for i in range(59,-1,-1):
            if num-2**i>=0:
                bit[i].append(s);num-=2**i;info[vals[s]].append(i)
    graph=[[] for s in range(n)];tracker=[set([]) for s in range(n)]
    for s in range(n):
        for i in info[vals[s]]:
            for b in range(len(bit[i])):
                if bit[i][b]!=s and not(bit[i][b] in tracker[s]):
                    graph[s].append(bit[i][b]);tracker[s].add(bit[i][b])
    print(shortest_cycle(n))