Problem: Janusz is a businessman. He owns a company "Januszex", which produces games for teenagers. Last hit of Januszex was a cool one-person game "Make it one". The player is given a sequence of n integers a_i.

It is allowed to select any subset of them, and the score is equal to the greatest common divisor of selected elements. The goal is to take as little elements as it is possible, getting the score 1. Now Janusz wonders, for given sequence, how much elements should the player choose?

Input

The first line contains an only integer n (1 ≤ n ≤ 300 000) — the number of integers in the sequence.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000).

Output

If there is no subset of the given sequence with gcd equal to 1, output -1.

Otherwise, output exactly one integer — the size of the smallest subset with gcd equal to 1.

Examples

Input

3
10 6 15


Output

3


Input

3
2 4 6


Output

-1


Input

7
30 60 21 42 70 15 30


Output

3

Note

In the first example, selecting a subset of all numbers gives a gcd of 1 and for all smaller subsets the gcd is greater than 1.

In the second example, for all subsets of numbers the gcd is at least 2. 

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FMakeItOne solver = new FMakeItOne();
        solver.solve(1, in, out);
        out.close();
    }

    static class FMakeItOne {
        long mod = 1000000009;
        long[] fact;

        long findIt(long n, long r) {
            if (r > n) return 0;
            return (fact[(int) n] * CodeHash.modInverse((fact[(int) (n - r)] * fact[(int) r]) % mod, mod)) % mod;
        }

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            fact = new long[300005];
            fact[0] = 1;
            for (int i = 1; i < 300005; i++) fact[i] = (fact[i - 1] * i) % mod;
            long[][] dp = new long[8][300005];
            int n = in.scanInt();
            int[] ar = new int[n];
            int[] cnt = new int[300005];
            long gcd = ar[0] = in.scanInt();
            cnt[ar[0]]++;
            for (int i = 1; i < n; i++) {
                ar[i] = in.scanInt();
                gcd = CodeHash.gcd(gcd, ar[i]);
                cnt[ar[i]]++;
            }
            if (gcd != 1) {
                out.println(-1);
                return;
            }
            for (int i = 1; i <= 300000; i++)
                for (int j = 2 * i; j <= 300000; j += i) cnt[i] += cnt[j];

            for (int i = 1; i < 8; i++) {
                for (int j = 300000; j >= 1; j--) {
                    dp[i][j] = findIt(cnt[j], i) % mod;
                    for (int k = 2 * j; k <= 300000; k += j) dp[i][j] = (mod - dp[i][k] + dp[i][j]) % mod;
                }
                if (dp[i][1] != 0) {
                    out.println(i);
                    return;
                }
            }
            throw new RuntimeException("NONONO");
        }

    }

    static class CodeHash {
        public static long[] euclidExtended(long a, long b) {
            if (b == 0) {
                long ar[] = new long[]{1, 0};
                return ar;
            }
            long ar[] = euclidExtended(b, a % b);
            long temp = ar[0];
            ar[0] = ar[1];
            ar[1] = temp - (a / b) * ar[1];
            return ar;
        }

        public static long modInverse(long a, long m) {
            long ar[] = euclidExtended(a, m);
            return ((ar[0] % m) + m) % m;
        }

        public static long gcd(long a, long b) {
            if (b == 0)
                return a;
            else
                return gcd(b, a % b);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}