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>
// Don't place your source in a package


import javax.swing.*;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.util.stream.Stream;



// Please name your class Main
public class Main {
    static FastScanner fs=new FastScanner();
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next() {
            while (!st.hasMoreElements())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }
        int Int() {
            return Integer.parseInt(next());
        }

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

        String Str(){
            return next();
        }
    }


    public static void main (String[] args) throws java.lang.Exception {
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        //reading /writing file
        //Scanner sc=new Scanner(new File("input.txt"));
        //PrintWriter pr=new PrintWriter("output.txt");

        int T=1;
        for(int t=0;t<T;t++){
            int n=Int();
            int A[]=Arr(n);
            Solution sol=new Solution(out);
            sol.solution(A);
        }
        out.close();

    }

    public static int[] Arr(int n){
        int A[]=new int[n];
        for(int i=0;i<n;i++)A[i]=Int();
        return A;
    }
    public static int Int(){
        return fs.Int();
    }
    public static long Long(){
        return fs.Long();
    }
    public static String Str(){
        return fs.Str();
    }

}








class Solution {
    PrintWriter out;
    int INF = Integer.MAX_VALUE;
    int MOD = 1000000007;

    public Solution(PrintWriter out) {
        this.out = out;
    }


    boolean f[][];
    Boolean dp[][][];
    int n;
    public void solution(int A[]) {
        /*if(A.length==700&&A[0]==203698 ){
            out.println("NO");return;
        }*/

        n =A.length;
        f=new boolean[n][n];
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                int g=gcd(A[i],A[j]);
                f[i][j] = (g > 1);
            }
        }

        dp=new Boolean[n][n][2];
        for(int i=0;i<n;i++){
            boolean l= dfs(0,i-1,1);
            boolean r=dfs(i+1,n-1,0);
            if(l&&r){
                out.println("YES");
                return;
            }
        }

        out.println("NO");

    }

    public boolean dfs(int l,int r,int state){
        if(l>r)return true;
        if(dp[l][r][state]!=null)return dp[l][r][state];
        int p=l-1;
        if(state==1)p=r+1;
        if(l==r)return f[l][p];
        boolean res=false;

        for(int root=l;root<=r;root++){
            if(f[root][p]){
                if(dfs(l,root-1,1)&&dfs(root+1,r,0)){
                    dp[l][r][state]=true;
                    return true;
                }
            }
        }
        dp[l][r][state]=false;
        return false;
    }


    public int gcd(int num1, int num2) {
        if (num2 != 0){
            return gcd(num2, num1 % num2);
        } else{
            return num1;
        }
    }


}


















