#include <bits/stdc++.h>
using namespace std;
long long n, a[100005];
int main() {
  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;
  }
  for (int i = 2; i <= n; ++i)
    if (a[i] != a[1]) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
  return 0;
}
