#include <bits/stdc++.h>
int main(int argc, const char* argv[]) {
  long long n, a[100000], i, c;
  std::string s;
  c = 0;
  std::cin >> n;
  for (i = 0; i < n; i++) {
    std::cin >> a[i];
    while (a[i] % 2 == 0) {
      a[i] = a[i] / 2;
    }
    while (a[i] % 3 == 0) {
      a[i] = a[i] / 3;
    }
  }
  for (i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      s = "NO";
      break;
    } else {
      c++;
    }
  }
  if (c == n - 1) {
    s = "YES";
  }
  std::cout << s << std::endl;
  return 0;
}
