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