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