#include <bits/stdc++.h>
using namespace std;
const int MxN = 2e5 + 5;
int a[MxN];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    while (a[i] % 2 == 0) {
      a[i] /= 2;
    }
    while (a[i] % 3 == 0) {
      a[i] /= 3;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] != a[0]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
