#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  bool check = 0;
  for (int i = 1; i <= n; i++) {
    while (a[i] % 2 == 0) a[i] /= 2;
    while (a[i] % 3 == 0) a[i] /= 3;
    if (a[i] != a[i - 1] && i > 1) check = 1;
  }
  if (check)
    printf("NO");
  else
    printf("YES");
  return 0;
}
