#include <bits/stdc++.h>
using namespace std;
int INF = (1LL << 30) - 1;
int MOD = 1e9 + 7;
int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = int(0); i < int(N); ++i) cin >> V[i];
  set<int> st;
  for (int i = int(0); i < int(N); ++i) {
    while (V[i] % 2 == 0) V[i] /= 2;
    while (V[i] % 3 == 0) V[i] /= 3;
    st.insert(V[i]);
  }
  if (st.size() == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
