#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 1912;
int n;
int a[maxn];
int main() {
  std ::ios_base::sync_with_stdio(false);
  cin.tie(0);
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%d", &a[i]);
  for (int i = (1); i <= (n); i++) {
    while (a[i] % 2 == 0) a[i] /= 2;
    while (a[i] % 3 == 0) a[i] /= 3;
  }
  int tmp = a[1];
  for (int i = (1); i <= (n); i++)
    if (a[i] != tmp) {
      puts("NO");
      return 0;
    }
  puts("YES");
  return 0;
}
