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