#include <bits/stdc++.h>
int main() {
  int n;
  int cur;
  scanf("%d", &n);
  scanf("%d", &cur);
  while (!(cur & 1)) {
    cur >>= 1;
  }
  while (cur % 3 == 0) {
    cur /= 3;
  }
  for (int i = 1; i < n; ++i) {
    int tmp;
    scanf("%d", &tmp);
    while (!(tmp & 1)) {
      tmp >>= 1;
    }
    while (tmp % 3 == 0) {
      tmp /= 3;
    }
    if (tmp != cur) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
}
