#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;
const long long linf = (1ll << 62) - 1;
int main() {
  int n, m, t, c, d, inf = 1e+5 + 5, jav = inf;
  scanf("%i", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%i", &a[i]);
    while (a[i] % 2 == 0) a[i] /= 2;
    while (a[i] % 3 == 0) a[i] /= 3;
    if (i && a[i] != a[0]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
}
