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:
//package que_a;

import java.io.*;
import java.util.*;
import java.math.*;

public class utkarsh {

    InputStream is;
    PrintWriter out;
    
    long mod = (long) (1e9 + 7), inf = (long) (3e18);
    
    void solve() {
        int n = ni();
        int a[] = na(n);
        int gcd = a[0];
        for(int x : a)  gcd = gcd(gcd, x);
        if(gcd > 1) {
            out.println(-1);    return;
        }
        int z = 300300;
        int spf[] = new int[z];
        for(int i = 0; i < z; i++) spf[i] = i;
        for(int i = 2; i*i < z; i++) {
            if(spf[i] != i) continue;
            for(int j = i*i; j < z; j += i) {
                if(spf[j] == j) spf[j] = i;
            }
        }
        ArrayList <Integer> d[] = new ArrayList[n];
        int h[] = new int[z];
        for(int i = 0; i < n; i++) {
            d[i] = new ArrayList<>();
            int x = a[i];
            h[x] = 1;
            while(x > 1) {
                d[i].add(spf[x]);
                int u = spf[x];
                while(spf[x] == u)  x /= spf[x];
            }
        }
        for(int i = 1; i < z; i++) {
            for(int j = i+i; j < z; j += i) {
                h[i] += h[j];       // count of multiples of i present in the array
            }
        }
        int ans = 7;
        for(int i = 0; i < n; i++) {
            int sz = d[i].size();
            int dp[] = new int[1 << sz];
            for(int k = 0; k < (1 << sz); k++) {
                int u = 1;
                for(int j = 0; j < sz; j++) {
                    if(((k >> j) & 1) == 1) u *= d[i].get(j);
                }
                dp[k] = h[u];
            }
            for(int j = 0; j < sz; j++) {
                for(int k = 0; k < (1 << sz); k++) {
                    if(((k >> j) & 1) == 1) dp[k ^ (1 << j)] -= dp[k];
                }
            }
            for(int j = 0; j < sz; j++) {
                for(int k = 0; k < (1 << sz); k++) {
                    if(((k >> j) & 1) == 1) dp[k] += dp[k ^ (1 << j)];
                }
            }
            int ap[] = new int[1 << sz];
            ap[0] = 1;
            for(int k = 1; k < (1 << sz); k++) {
                ap[k] = n+1;
                int u = k;
                while(u > 0) {
                    if(dp[(1 << sz) - 1 - u] > 0)   ap[k] = Math.min(ap[k], ap[k - u] + 1);
                    u = (u - 1) & k;
                }
            }
            ans = Math.min(ans, ap[(1 << sz) - 1]);
        }
        out.println(ans);
    }
    
    int gcd(int a, int b) {
        if(b == 0)  return a;
        return gcd(b, a%b);
    }
    
    long mp(long b, long e) {
        long r = 1;
        while(e > 0) {
            if((e&1) == 1)  r = (r * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return r;
    }

    //---------- I/O Template ----------
    
    public static void main(String[] args) { new utkarsh().run(); }
    void run() { 
        is = System.in;
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }
    
    byte input[] = new byte[1024];
    int len = 0, ptr = 0;
    
    int readByte() { 
        if(ptr >= len) { ptr = 0; 
            try { len = is.read(input); } 
            catch(IOException e) { throw new InputMismatchException(); } 
            if(len <= 0) { return -1; } 
        } return input[ptr++];
    }
    boolean isSpaceChar(int c) { return !( c >= 33 && c <= 126 ); }
    int skip() { 
        int b = readByte(); 
        while(b != -1 && isSpaceChar(b)) { b = readByte(); } 
        return b;
    }
    
    char nc() { return (char)skip(); }
    String ns() { 
        int b = skip(); 
        StringBuilder sb = new StringBuilder(); 
        while(!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); } 
        return sb.toString();
    }
    String nLine() { 
        int b = skip(); 
        StringBuilder sb = new StringBuilder(); 
        while( !(isSpaceChar(b) && b != ' ') ) { sb.appendCodePoint(b); b = readByte(); } 
        return sb.toString();
    }
    int ni() { 
        int n = 0, b = readByte(); 
        boolean minus = false; 
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); } 
        if(b == '-') { minus = true; b = readByte(); } 
        if(b == -1) { return -1; }  //no input 
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); } 
        return minus ? -n : n;
    }
    long nl() { 
        long n = 0L;    int b = readByte(); 
        boolean minus = false; 
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); } 
        if(b == '-') { minus = true; b = readByte(); } 
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); } 
        return minus ? -n : n;
    }

    double nd() { return Double.parseDouble(ns()); }
    float nf() { return Float.parseFloat(ns()); }
    int[] na(int n) { 
        int a[] = new int[n]; 
        for(int i = 0; i < n; i++) { a[i] = ni(); } 
        return a;
    }
    char[] ns(int n) { 
        char c[] = new char[n]; 
        int i, b = skip(); 
        for(i = 0; i < n; i++) { 
            if(isSpaceChar(b)) { break; } 
            c[i] = (char)b; b = readByte(); 
        } return i == n ? c : Arrays.copyOf(c,i);
    }
}