#include <bits/stdc++.h>
using namespace std;
int main() {
  int m;
  cin >> m;
  set<int> a;
  for (int i = 0; i < m; ++i) {
    int n;
    cin >> n;
    while (n % 2 == 0) n /= 2;
    while (n % 3 == 0) n /= 3;
    a.insert(n);
  }
  if (a.size() == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
