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>
/**
 * BaZ :D
 */
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main
{  
    static Reader sDP_NAA_HO_PAAYEGA;
    static PrintWriter pw;
    static int n,RECURSIVE_DP_IN_JAVA_SUCKS[][],RECURSIVE_DP_IN_JAVA_SUCKS_[][],FUCKKKKKKKKKKKK[];
    static boolean DP_NAA_HO_PAAYEGA[][];
    public static void main(String[] args) {
        new Thread(null,null,"BaZ",1<<25)
        {
           public void run()
           {
               try
               {
                   solve();
               }
               catch(Exception e)
               {  
                   e.printStackTrace();
                   System.exit(1);
               }
           }
        }.start();
    }
    static void solve() throws IOException
    {
        sDP_NAA_HO_PAAYEGA = new Reader();
        pw = new PrintWriter(System.out,true);
        StringBuilder sb = new StringBuilder();
        n = ni();
        FUCKKKKKKKKKKKK = new int[n];
        DP_NAA_HO_PAAYEGA = new boolean[n][n];
        RECURSIVE_DP_IN_JAVA_SUCKS_ = new int[n][n];
        RECURSIVE_DP_IN_JAVA_SUCKS = new int[n][n];
        for(int i=0;i<n;++i)
            for(int j=0;j<n;++j)
                RECURSIVE_DP_IN_JAVA_SUCKS[i][j] = RECURSIVE_DP_IN_JAVA_SUCKS_[i][j] = -1;
        for(int i=0;i<n;++i)
        {
            FUCKKKKKKKKKKKK[i] = ni();
            DP_NAA_HO_PAAYEGA[i][i] = true;
            RECURSIVE_DP_IN_JAVA_SUCKS[i][i] = RECURSIVE_DP_IN_JAVA_SUCKS_[i][i] = 1;
            for(int j=0;j<i;++j)
                if(gcd(FUCKKKKKKKKKKKK[i],FUCKKKKKKKKKKKK[j])>1)
                    DP_NAA_HO_PAAYEGA[i][j] = DP_NAA_HO_PAAYEGA[j][i] = true;
        }
        boolean yes = false;
        for(int i=0;i<n;++i)
            if(f(0,i,1)==1 && f(i,n-1,0)==1)
            {
                yes = true;
                break;
            }
        if(yes)
            pl("Yes");
        else pl("No");
        pw.flush();
        pw.close();
    }
    static int f(int l,int r,int side)
    {
        if(side==0)
        {   
            if(RECURSIVE_DP_IN_JAVA_SUCKS[l][r]!=-1)
                return RECURSIVE_DP_IN_JAVA_SUCKS[l][r];
            for(int i=l+1;i<=r;++i)
            {
                if(DP_NAA_HO_PAAYEGA[l][i] && f(l+1,i,1)==1 && f(i,r,0)==1)
                {
                    RECURSIVE_DP_IN_JAVA_SUCKS[l][r]=1;
                    break;
                }
            }
            if(RECURSIVE_DP_IN_JAVA_SUCKS[l][r]==-1)
                RECURSIVE_DP_IN_JAVA_SUCKS[l][r]++;
            return RECURSIVE_DP_IN_JAVA_SUCKS[l][r];
        }
        else
        {   
            if(RECURSIVE_DP_IN_JAVA_SUCKS_[l][r]!=-1)
                return RECURSIVE_DP_IN_JAVA_SUCKS_[l][r];
            for(int i=l;i<r;++i)
            {
                if(DP_NAA_HO_PAAYEGA[i][r] && f(l,i,1)==1 && f(i,r-1,0)==1)
                {
                    RECURSIVE_DP_IN_JAVA_SUCKS_[l][r] = 1;
                    break;
                }
            }
            if(RECURSIVE_DP_IN_JAVA_SUCKS_[l][r]==-1)
                RECURSIVE_DP_IN_JAVA_SUCKS_[l][r]++;
            return RECURSIVE_DP_IN_JAVA_SUCKS_[l][r];
        }
    }
    static int gcd(int a,int b)
    {
        if(b==0)
            return a;
        return gcd(b,a%b);
    }
    static int ni() throws IOException
    {
        return sDP_NAA_HO_PAAYEGA.nextInt();
    }
    static long nl() throws IOException
    {
        return sDP_NAA_HO_PAAYEGA.nextLong();
    }
    static double nd() throws IOException
    {
        return sDP_NAA_HO_PAAYEGA.nextDouble();
    }
    static void pl()
    {
        pw.println();
    }
    static void p(Object o)
    {
        pw.print(o+" ");
    }
    static void pl(Object o)
    {
        pw.println(o);
    }
    static void psb(StringBuilder sb)
    {
        pw.print(sb);
    }
    static void pa(String FUCKKKKKKKKKKKKayName, Object FUCKKKKKKKKKKKK[])
    {  
        pl(FUCKKKKKKKKKKKKayName+" : ");
        for(Object o : FUCKKKKKKKKKKKK)
            p(o);
        pl();
    }
    static void pa(String FUCKKKKKKKKKKKKayName, int FUCKKKKKKKKKKKK[])
    {
        pl(FUCKKKKKKKKKKKKayName+" : ");
        for(int o : FUCKKKKKKKKKKKK)
            p(o);
        pl();
    }
    static void pa(String FUCKKKKKKKKKKKKayName, long FUCKKKKKKKKKKKK[])
    {
        pl(FUCKKKKKKKKKKKKayName+" : ");
        for(long o : FUCKKKKKKKKKKKK)
            p(o);
        pl();
    }
    static void pa(String FUCKKKKKKKKKKKKayName, double FUCKKKKKKKKKKKK[])
    {
        pl(FUCKKKKKKKKKKKKayName+" : ");
        for(double o : FUCKKKKKKKKKKKK)
            p(o);
        pl();
    }
    static void pa(String FUCKKKKKKKKKKKKayName, char FUCKKKKKKKKKKKK[])
    {
        pl(FUCKKKKKKKKKKKKayName+" : ");
        for(char o : FUCKKKKKKKKKKKK)
            p(o);
        pl();
    }
    static class Reader {
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader() {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException {
        byte[] buf = new byte[64];
        int cnt = 0, c;
        while ((c = read()) != -1) {
            if (c == '\n') break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }

    public long nextLong() throws IOException {
        long ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }

    public double nextDouble() throws IOException {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
        if (neg) return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) buffer[0] = -1;
    }

    private byte read() throws IOException {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException {
        if (din == null) return;
        din.close();
    }
}
}