#include <bits/stdc++.h>
using namespace std;
bool myfunction(int i, int j) { return (j < i); }
int n, i, arr[100005], two[100005], three[100005], max2, max3;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < n; i++) {
    int m2, m3;
    while (arr[i] % 2 == 0) {
      arr[i] = arr[i] / 2;
      m2++;
    }
    while (arr[i] % 3 == 0) {
      arr[i] = arr[i] / 3;
      m3++;
    }
    if (m2 > max2) max2 = m2;
    if (m3 > max3) max3 = m3;
  }
  for (i = 0; i < n; i++) {
    arr[i] == arr[i] * max3* max2;
  }
  for (i = 0; i < n - 1; i++) {
    if (arr[i] != arr[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
