#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
inline T max(T &a, U &b) {
  return a > b ? a : b;
}
template <class T, class U>
inline T min(T &a, U &b) {
  return a < b ? a : b;
}
template <class T, class U>
inline T swap(T &a, U &b) {
  T tmp = a;
  a = b;
  b = tmp;
}
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class X, class Y, class Z>
X BigMod(X B, Y P, Z M) {
  if (P == 0) return 1;
  if (P % 2 == 1) {
    return ((B % M) * BigMod(B, P - 1, M)) % M;
  }
  X P2 = BigMod(B, P / 2, M);
  return (P2 * P2) % M;
}
map<int, int> mp, color;
void dfs(int u) {
  color[u] = 1;
  mp[u]++;
  if (u % 2 == 0 && color[u / 2] == 0 && u / 2 > 0) dfs(u / 2);
  if (u % 3 == 0 && color[u / 3] == 0 && u / 3 > 0) dfs(u / 3);
  color[u] = 2;
}
int main() {
  int n;
  while (cin >> n) {
    mp.clear();
    vector<int> v;
    for (__typeof(0) i = (0); i <= (n - 1); ++i) {
      int a = ({
        int a;
        scanf("%d", &a);
        a;
      });
      v.push_back(a);
      dfs(a);
      color.clear();
    }
    bool res = false;
    for (__typeof((mp).end()) i = (mp).begin(); i != (mp).end(); i++) {
      if (i->second == n) res = true;
    }
    if (res)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
