Dima the hamster enjoys nibbling different things: cages, sticks, bad problemsetters and even trees!

Recently he found a binary search tree and instinctively nibbled all of its edges, hence messing up the vertices. Dima knows that if Andrew, who has been thoroughly assembling the tree for a long time, comes home and sees his creation demolished, he'll get extremely upset. 

To not let that happen, Dima has to recover the binary search tree. Luckily, he noticed that any two vertices connected by a direct edge had their greatest common divisor value exceed 1.

Help Dima construct such a binary search tree or determine that it's impossible. The definition and properties of a binary search tree can be found [here.](https://en.wikipedia.org/wiki/Binary_search_tree)

Input

The first line contains the number of vertices n (2 ≤ n ≤ 700).

The second line features n distinct integers a_i (2 ≤ a_i ≤ 10^9) — the values of vertices in ascending order.

Output

If it is possible to reassemble the binary search tree, such that the greatest common divisor of any two vertices connected by the edge is greater than 1, print "Yes" (quotes for clarity).

Otherwise, print "No" (quotes for clarity).

Examples

Input

6
3 6 9 18 36 108


Output

Yes


Input

2
7 17


Output

No


Input

9
4 8 10 12 15 18 33 44 81


Output

Yes

Note

The picture below illustrates one of the possible trees for the first example.

<image>

The picture below illustrates one of the possible trees for the third example.

<image>
import java.io.*;
import java.util.*;

public class Contest1 {
    static boolean[][][]memo,vis;
    static long[]a;
    static boolean dp(int s,int l,int r){
        if (l>r)return true;
        if (vis[s][l][r])return memo[s][l][r];
        int root=-1;
        if (s==0)root=r+1;
        else root=l-1;
        boolean ans=false;
        for (int i =l;i<=r&&!ans;i++){
            if (gcd[root][i]>1){
                ans|=dp(0,l,i-1)&&dp(1,i+1,r);
            }
        }
        vis[s][l][r]=true;
        return memo[s][l][r]=ans;
    }
    static long[][]gcd;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        a= new long[n+1];
        TreeSet<Integer>ts= new TreeSet<>();
        long lcm=1;
        gcd= new long[n+1][n+1];
        for (int i =1;i<=n;i++){
            a[i]=sc.nextInt();
            long g= gcd(lcm,a[i]);
            lcm/=g;
            lcm*=a[i];
        }
        a[0]=lcm;
        for (int i =0;i<=n;i++){
            for (int j =0;j<=n;j++){
                gcd[i][j]=gcd(a[i],a[j]);
            }
        }
//        if (ts.size()<n){
//            System.out.println("NO");
//            return;
//        }
       memo= new boolean[2][n+1][n+1];
       vis= new boolean[2][n+1][n+1];
       pw.println(dp(1,1,n)?"YES":"NO");
        pw.flush();
    }
    static long gcd(long a,long b){
        if (a==0)return b;
        return gcd(b%a,a);
    }
    static class Scanner{
        StringTokenizer st;
        BufferedReader br;
        public  Scanner(InputStream s){
            br = new BufferedReader(new InputStreamReader(s));
        }
        public String next() throws IOException{
            while (st==null||!st.hasMoreTokens())st= new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public String nextLine() throws IOException {return br.readLine();};
        public int nextInt() throws IOException {return Integer.parseInt(next());}
        public long nextLong() throws IOException {return Long.parseLong(next());}

    }
}