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.lang.*;
import java.math.*;
import java.util.*;
import java.io.*;
public class Main {
    void solve() {
        int n=ni();
        HashSet<Integer>hs=new HashSet<>();
        for(int i=1;i<=n;i++){
            int a=ni();
            int num=1;
            for(int j=2;j*j<=a;j++){
                if(a%j==0){
                    while(a%j==0){
                        a/=j;
                    }
                    num*=j;
                }
            }
            num*=a;
            hs.add(num);
        }

        int cnt[]=new int[MX+1];
        for(int u : hs) {
            cnt[u] = 1;
           // pw.println(u);
        }

        for(int i=1;i<=MX;i++){
            for(int j=2*i;j<=MX;j+=i) cnt[i]+=cnt[j];
        }
      //  for(int i=1;i<=MX;i++) if(cnt[i]>0) pw.println(i+" "+cnt[i]);
        long dp[]=new long[MX+1];
        precompute();
        for(int i=1;i<=7;i++){
            Arrays.fill(dp,0);
            for(int j=MX;j>=1;j--){
                //if(cnt[j]>MX) System.out.println(j+" "+cnt[j]);
                dp[j]=ncr(cnt[j],i);


                for(int k=2;k*j<=MX;k++){
                    dp[j]=sub(dp[j],dp[k*j]);
                }
            }
            if(dp[1]>0){
                pw.println(i);
                return;
            }
        }
        pw.println("-1");
    }
    long fact[];
    long inv[];
    int MX=300000;
    long ncr(int n,int r){
        if(r>n) return 0;
        long ans=fact[n];
        ans=mul(ans,inv[r]);
        ans=mul(ans,inv[n-r]);
        return ans;
    }
    void precompute(){
        fact=new long[MX+1];
        inv=new long[MX+1];
        fact[0]=1;
        for(int i=1;i<=MX;i++) fact[i]=(fact[i-1]*i)%M;
        inv[MX]=modInverse(fact[MX],M);
        for(int i=MX-1;i>=0;i--){
            inv[i]=mul(inv[i+1],i+1);
        }
    }

    long add(long x,long y){
        x+=y;
        if(x>=M) x-=M;
        return x;
    }
    long sub(long x,long y){
        x-=y;
        if(x<0) x+=M;
        return x;
    }
    long mul(long x,long y){
        x*=y;
        if(x>=M) x%=M;
        return x;
    }
    long modpow(long a, long b)
    {
        long r=1;
        while(b>0)
        {
            if((b&1)>0) r=mul(r,a);
            a=mul(a,a);
            b>>=1;
        }
        return r;
    }

    long modInverse(long A, long M)
    {

        return modpow(A,M-2);
    }





    long M= (long)1e9+7;
    InputStream is;
    PrintWriter pw;
    String INPUT = "";
    void run() throws Exception {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
        if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");

    }
    public static void main(String[] args) throws Exception { new Main().run(); }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if(lenbuf == -1)throw new InputMismatchException();
        if(ptrbuf >= lenbuf){
            ptrbuf = 0;
            try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
            if(lenbuf <= 0)return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
    private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

    private double nd() { return Double.parseDouble(ns()); }
    private char nc() { return (char)skip(); }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while(p < n && !(isSpaceChar(b))){
            buf[p++] = (char)b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for(int i = 0;i < n;i++)map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for(int i = 0;i < n;i++)a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }
    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
    private void tr(Object... o) { if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o)); }

}