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