#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, i, c1 = 0;
  cin >> n;
  long long a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  set<long long> st;
  for (i = 0; i < n; i++) {
    while (a[i] % 2 == 0) {
      a[i] /= 2;
    }
    while (a[i] % 3 == 0) {
      a[i] /= 3;
    }
    st.insert(a[i]);
  }
  if (st.size() == 1)
    cout << "YES\n";
  else
    cout << "NO\n";
}
