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