#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  long long n, k, s = 1;
  cin >> n;
  long long z[n], zmp[n], min = 10e9;
  for (long long i = 0; i < n; ++i) cin >> z[i];
  k = gcd(z[0], z[1]);
  for (long long i = 2; i < n; ++i) k = gcd(k, z[i]);
  for (long long i = 0; i < n; ++i) {
    long long tmp = z[i] / k;
    while (tmp % 2 == 0) tmp /= 2;
    while (tmp % 3 == 0) tmp /= 3;
    if (tmp != 1) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
