#include <bits/stdc++.h>
void out2(int &a) {
  while (a % 2 == 0) {
    a /= 2;
  }
}
void out3(int &a) {
  while (a % 3 == 0) {
    a /= 3;
  }
}
int main() {
  int n;
  while (scanf("%d", &(n)) != EOF) {
    int a;
    scanf("%d", &(a));
    out2(a);
    out3(a);
    bool ok = true;
    for (int i = 1; i < n; i++) {
      int b;
      scanf("%d", &(b));
      if (!ok) continue;
      out2(b);
      out3(b);
      if (b != a) {
        ok = false;
      }
    }
    puts(ok ? "YES" : "NO");
  }
  return 0;
}
