#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> x;
  int n, t;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t;
    x.push_back(t);
  }
  for (int i = 0; i < x.size(); i++) {
    while (x[i] % 2 == 0 || x[i] % 3 == 0) {
      if (x[i] % 2 == 0)
        x[i] /= 2;
      else
        x[i] /= 3;
    }
  }
  int a = x[n - 1];
  int b = x[n - 2];
  if (a != b) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = 0; i < x.size(); i++) {
    if (x[i] != a) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
