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