#include <bits/stdc++.h>
const long long int MAX = 1e12;
using namespace std;
const int alpha = 26;
void solve() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (auto &it : arr) cin >> it;
  for (int i = 0; i < n; i++) {
    while (arr[i] % 2 == 0) arr[i] /= 2;
    while (arr[i] % 3 == 0) arr[i] /= 3;
  }
  if (count(arr.begin(), arr.end(), arr[0]) == n)
    cout << "YES";
  else
    cout << "NO";
}
int main() {
  solve();
  return 0;
}
