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