#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e, f, g, h, j, k, i;
  cin >> a;
  int ar[100005];
  for (i = 0; i < a; i++) {
    cin >> ar[i];
    while (ar[i] % 2 == 0) {
      ar[i] /= 2;
    }
    while (ar[i] % 3 == 0) {
      ar[i] /= 3;
    }
  }
  for (i = 0; i < a - 1; i++) {
    if (ar[i] != ar[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
