#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  bool flag = true;
  int temp;
  cin >> temp;
  while (temp % 2 == 0) temp /= 2;
  while (temp % 3 == 0) temp /= 3;
  for (long long i = (1); i < (n); ++i) {
    int temp1;
    cin >> temp1;
    while (temp1 % 2 == 0) temp1 /= 2;
    while (temp1 % 3 == 0) temp1 /= 3;
    if (temp != temp1) flag = false;
  }
  if (flag)
    cout << "YES";
  else
    cout << "NO";
  cout << '\n';
  return 0;
}
