#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100001];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  while (a[0] % 2 == 0) a[0] = a[0] / 2;
  while (a[0] % 3 == 0) a[0] = a[0] / 3;
  int min_val = a[0];
  bool ans = true;
  for (int i = 1; i < n; i++) {
    while (a[i] % 2 == 0) a[i] = a[i] / 2;
    while (a[i] % 3 == 0) a[i] = a[i] / 3;
    if (a[i] != a[0]) {
      ans = false;
      break;
    }
  }
  if (ans)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
