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