#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
int main() {
  int n;
  cin >> n;
  long long int a;
  cin >> a;
  while (1) {
    if (a % 2 == 0)
      a /= 2;
    else if (a % 3 == 0)
      a /= 3;
    else
      break;
  }
  bool f = 1;
  for (int i = 0; i < n; i++) {
    long long int b;
    cin >> b;
    while (1) {
      if (b % 2 == 0)
        b /= 2;
      else if (b % 3 == 0)
        b /= 3;
      else
        break;
    }
    if (a != b) f = 0;
    a = b;
  }
  if (f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
