#include <bits/stdc++.h>
using namespace std;
double err = 0.0000001;
int f(int x) {
  while (x % 2 == 0) x /= 2;
  while (x % 3 == 0) x /= 3;
  return x;
}
int main() {
  int n, x;
  cin >> n >> x;
  int res = f(x);
  bool ok = 1;
  for (int i = 1; i < n && ok; i++) {
    cin >> x;
    x = f(x);
    if (x != res) ok = 0;
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
