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.
//Created by Aminul on 8/19/2019.

import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class D {
    static int inf = (int) 1e9;

    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        ArrayDeque<Integer> dq[] = genDQ(62);
        int n = in.nextInt();

        for (int i = 0; i < n; i++) {
            long x = in.nextLong();
            for (int j = 0; j < 62; j++) {
                if (!check(x, j)) continue;
                dq[j].addLast(i);
                if (dq[j].size() >= 3) {
                    pw.println(3);
                    pw.close();
                    return;
                }
            }
        }

        ArrayDeque<Integer> g[] = genDQ(125);
        HashMap<Integer, Integer> map = new HashMap();
        int idx = 0;
        for (int i = 0; i < 62; i++) {
            if (dq[i].size() < 2) continue;
            int f = dq[i].getFirst(), s = dq[i].getLast();
            if (!map.containsKey(f)) map.put(f, idx++);
            if (!map.containsKey(s)) map.put(s, idx++);
            f = map.get(f);
            s = map.get(s);
            g[f].addLast(s);
            g[s].addLast(f);
        }

        pw.println(bfs(125, g));

        pw.close();
    }

    static int bfs(int n, ArrayDeque<Integer> g[]) {
        int res = inf;
        int[] vis = new int[n];
        for (int u = 0; u < n; u++) {
            if (g[u].size() < 2) continue;
            Queue<Integer> q = new ArrayDeque<>();
            Arrays.fill(vis, inf);
            vis[u] = 0;
            q.add(u);
            HashSet<Long> set = new HashSet<>();
            while (!q.isEmpty()) {
                int p = q.poll();
                for (int v : g[p]) {
                    long hash = getHash(v, p);
                    //debug(p, v);
                    if (vis[v] == inf) {
                        vis[v] = vis[p] + 1;
                        q.add(v);
                        set.add(hash);
                    } else if (set.add(hash)) {
                        //debug(u, v, p, vis[p] + vis[v] + 1 );
                        int add = 1;
                        if (vis[p] + vis[v] + add >= 3) res = min(res, vis[p] + vis[v] + add);
                    }
                }
            }
        }
        if (res >= inf) res = -1;
        return res;
    }

    static long getHash(long x, long y) {
        return (min(x, y) << 30) | max(x, y);
    }

    static <T> ArrayDeque<T>[] genDQ(int n) {
        ArrayDeque<T> list[] = new ArrayDeque[n];
        for (int i = 0; i < n; i++) list[i] = new ArrayDeque<T>();
        return list;
    }

    static boolean check(long N, int pos) {
        return (N & (1l << pos)) != 0;
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}