#include <bits/stdc++.h>
using namespace std;
int n, ok[777][777], a[777];
int l[777][777], r[777][777];
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  memset(ok, 0, sizeof(ok));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    l[i][i] = r[i][i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (gcd(a[i], a[j]) > 1) ok[i][j] = 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = i; j <= n; j++) {
      for (int k = i; k <= j; k++) {
        if (l[i][k] && r[k][j]) {
          if (i == 1 && j == n) {
            cout << "YES" << endl;
            return 0;
          }
          if (ok[i - 1][k]) r[i - 1][j] = 1;
          if (ok[k][j + 1]) l[i][j + 1] = 1;
        }
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}
