#include <bits/stdc++.h>
using namespace std;
int tm[100005];
int gcd(int a, int b) {
  int r;
  while (b > 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
int main() {
  int n, i, j, tt, m;
  scanf("%d", &n);
  scanf("%d", &tm[1]);
  int gd = tm[1];
  for (i = 2; i <= n; i++) {
    scanf("%d", &tm[i]);
    gd = gcd(gd, tm[i]);
  }
  for (i = 1; i <= n; i++) tm[i] /= gd;
  int flag = 0;
  for (i = 1; i <= n; i++) {
    while (tm[i] % 2 == 0) tm[i] /= 2;
    while (tm[i] % 3 == 0) tm[i] /= 3;
    if (tm[i] == 1)
      continue;
    else {
      flag = 1;
      break;
    }
  }
  if (flag)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
