#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int rax(long long int a) {
  while (a > 1) {
    if (a % 2 == 0) {
      a /= 2;
    } else if (a % 3 == 0) {
      a /= 3;
    } else
      break;
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long int> vec;
  int k;
  cin >> k;
  vec.push_back(k);
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    k = gcd(k, p);
    vec.push_back(p);
  }
  for (int i = 0; i < n; i++) {
    vec[i] /= k;
    vec[i] = rax(vec[i]);
    if (i > 0 && vec[i] != vec[i - 1]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
