#include <bits/stdc++.h>
using namespace std;
int n, a;
set<int> si;
int modes(int a) {
  while (a % 2 == 0) a /= 2;
  while (a % 3 == 0) a /= 3;
  return a;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    si.insert(modes(a));
  }
  if (si.size() == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
