#include <bits/stdc++.h>
using namespace std;
long long n, m, l, i, j, q, fin, maxx = -1e9, x;
long long ans, totalans = -1e9, ans1, anss;
int totalfot, totalhor, k1, k2;
string s, s1, s2;
int pref[100];
int dp[20][20][109][109];
vector<long long> num;
long long mynumber[525000];
set<char> myset;
int mychar[100];
pair<long long, pair<long long, long long> > number[10000];
int gcd(int a, int b) {
  for (;;) {
    if (a == 0) return b;
    b %= a;
    if (b == 0) return a;
    a %= b;
  }
}
int lcm(int a, int b) {
  int temp = gcd(a, b);
  return temp ? (a / temp * b) : 0;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> mynumber[i];
  for (int i = 0; i < n; i++) {
    while (mynumber[i] % 2 == 0) mynumber[i] /= 2;
    while (mynumber[i] % 3 == 0) mynumber[i] /= 3;
    if (i != 0 && mynumber[i] != mynumber[i - 1]) return cout << "NO", 0;
  }
  cout << "YES";
}
