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.math.BigInteger;
import java.util.*;
public class Main{
    static StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static BufferedReader buffer=new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc=new Scanner(System.in);
    static PrintWriter out=new PrintWriter(System.out);
    static InputReader input=new InputReader(System.in);
    static int N=100009;
    static Vector<Long> map[]=new Vector[62];
    static TreeMap<Long ,Integer> id;   //点的离散化
    static int now=0;
    static int arr[][]=new int[200][200];
    static int inf=(int)1e5;
    static int ans=inf;
    public static void main(String args[])throws Exception{

        for(int i=0;i<62;i++)map[i]=new Vector<Long>();
        id=new TreeMap<Long,Integer>();
        int n=input.nextInt();
        for(int i=0;i<n;i++){
            long x=input.nextLong();
            int j=0;
            long y=x;
            while(x!=0){
                if((x&1)==1){
                    map[j].add(y);
                    if(map[j].size()>=3){
                        System.out.println(3);
                        return;
                    }
                }
                j++;
                x>>=1;
            }
        }
        for(int i=0;i<62;i++){
            if(map[i].size()==2){
                long a=map[i].get(0);
                long b=map[i].get(1);
                //System.out.println(a+" "+b);
                int ax=put(a);
                int bx=put(b);
                arr[ax][bx]=arr[bx][ax]=1;
            }
        }
        init();
        Folyd();
        System.out.println(ans==inf?-1:ans);
    }

    static int dis[][]=new int[200][200];
    static int cnt,sum;
    static int path[]=new int[50000];
    static int pre[][]=new int[200][200];

    static void init() {
        for (int i = 0; i <now; ++i) {
            for (int j = 0; j <now; ++j) {
                pre[i][j] = i;
                 dis[i][j] = arr[i][j];
                 if(arr[i][j]==0)dis[i][j]=arr[i][j]=inf;
            }
            arr[i][i] = dis[i][i] = 0;
        }
    }
    static  void Folyd()
    {
        int mins = inf;
        for(int k = 0; k <now; ++k)
        {
            for(int i = 0; i < k; ++i)
                for(int j = i+1; j < k; ++j)
                {
                    //多一个graph数组的作用在于此，在松弛的过程中，会破坏掉两点之间是否真的存在边的表示，所有需要多开一个graph
                    int tmp = dis[i][j] + arr[k][i] + arr[j][k];
                    //正确写法应该是我这种写法即该环为j,k,i...j，菊苣的写法跟原理不对应，但不会出错，因为是无向图嘛。
                    if(mins > tmp)
                    {
                        mins = tmp;
                        cnt = 0; sum = 1;
                        int t = i;
                        while(t != j)
                        {
                            path[cnt++] = t;
                            t = pre[j][t];
                        }
                        path[cnt++] = j;
                        path[cnt++] = k;
                    }
                    else if(tmp == mins) ++sum;	//求不同的最小环的个数，i,j相同时可根据k区分，相同k可根据i,j区分，所以不会重。
                }
            for(int i = 0; i <now; ++i)
                for(int j = 0; j <now; ++j)
                {
                    if(dis[i][j] > dis[i][k]+dis[k][j])
                    {
                        dis[i][j] = dis[i][k]+dis[k][j];
                        pre[i][j] = pre[k][j];
                    }
                }
        }
        ans=mins;
    }

    static int put(long x){
        if(id.containsKey(x)){
            return id.get(x);
        }
        id.put(x,now);
        return now++;
    }
    static int getInt()throws Exception{
        in.nextToken();
        return (int)in.nval;
    }
}
class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;

    public InputReader(InputStream st) {
        this.stream = st;
    }

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

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public String readString() {
        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 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 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;
    }

}