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.util.*;
import java.lang.*;
import java.io.*;

public class Solution {
    static int N = 100005;
    static Map<Integer, List<Integer>> graph = new HashMap<>();
    static int[] distance = new int[N];
    static int[] parent = new int[N];
    static long n, minLengthCycle = Long.MAX_VALUE;
    public static void main(String[] args) throws java.lang.Exception {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new FastReader();
        int test = 1;
        for (int t = 0; t < test; t++) {
            solve();
        }
        out.close();
    }

    private static void solve() {
        n = sc.nextLong();
        Arrays.fill(parent, -1);
        Arrays.fill(distance, Integer.MAX_VALUE);
        for (int i = 0; i < n; i++) {
            graph.put(i, new ArrayList<>());
        }
        int[] countSetBits = new int[65];
        List<Long> goodNodes = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            long nodeVal = sc.nextLong();
            if (nodeVal > 0) {
                goodNodes.add(nodeVal);
            }
            int bit = 1;
            while (nodeVal > 0) {
                if (nodeVal % 2 == 1) {
                    countSetBits[bit]++;
                }
                if (countSetBits[bit] > 2) {
                    // min length of cycle possible
                    out.println(3);
                    return;
                }
                bit++;
                nodeVal /= 2;
            }
        }
        n = goodNodes.size();
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                long u = goodNodes.get(i);
                long v = goodNodes.get(j);
                if ((u & v) > 0) {
                    graph.get(i).add(j);
                    graph.get(j).add(i);
                }
            }
        }
        for (int i = 0; i < n; i++) {
            bfs(i);
        }
        if (minLengthCycle == Long.MAX_VALUE) {
            out.println(-1);
            return;
        }
        out.println(minLengthCycle);
    }

    private static void bfs(int node) {
        Arrays.fill(parent, -1);
        Arrays.fill(distance, Integer.MAX_VALUE);
        Queue<Integer> q = new LinkedList<>();
        parent[node] = -1;
        distance[node] = 0;
        q.add(node);
        while (!q.isEmpty()) {
            int curr = q.poll();
            for (int adj : graph.get(curr)) {
                if (distance[adj] == Integer.MAX_VALUE) {
                    q.add(adj);
                    parent[adj] = curr;
                    distance[adj] = distance[curr] + 1;
                } else if (distance[adj] >= distance[curr] && parent[adj] != curr) {
                    minLengthCycle = Math.min(minLengthCycle, distance[adj] + distance[curr] + 1);
                }
            }
        }
    }

    public static FastReader sc;
    public static PrintWriter out;
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}