#include <bits/stdc++.h>
using namespace std;
long long int arr[100010];
int main() {
  long long int num, i, flag, div;
  cin >> num;
  for (i = 0; i < num; i++) cin >> arr[i];
  sort(arr, arr + num);
  div = arr[0];
  flag = 1;
  for (i = 0; i < num; i++) {
    while (arr[i] % 2 == 0 || arr[i] % 3 == 0) {
      if (arr[i] % 2 == 0)
        arr[i] = arr[i] / 2;
      else
        arr[i] = arr[i] / 3;
    }
  }
  flag = 1;
  for (i = 0; i < num - 1; i++) {
    if (arr[i] != arr[i + 1]) {
      flag = 0;
      break;
    }
  }
  if (flag == 0)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
