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