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