#include <bits/stdc++.h>
using namespace std;
long long int Mod = 1e9 + 7;
vector<long long int> fact(1003, 1);
long long int mult(long long int a, long long int b) {
  long long int ret = 1;
  ret = ((a % Mod) * (b % Mod)) % Mod;
  return ret;
}
long long int power(long long int a, long long int b) {
  if (b == 0) return 1;
  long long int ret = 1;
  while (b) {
    if (b & 1) {
      ret = mult(ret, a);
    }
    a = mult(a, a);
    b >>= 1;
  }
  return ret;
}
void swap(int &a, int &b) {
  a = a + b;
  b = a - b;
  a = a - b;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void test_case() {
  int n;
  cin >> n;
  int a[n];
  int g = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    g = gcd(g, a[i]);
  }
  bool ok = 1;
  for (int i = 0; i < n; i++) {
    a[i] /= g;
    while (a[i] > 1) {
      while (a[i] % 2 == 0) a[i] /= 2;
      while (a[i] % 3 == 0) a[i] /= 3;
      if (a[i] > 1) {
        ok = 0;
        break;
      }
    }
  }
  if (ok) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    test_case();
  }
}
