#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int arr[100005];
int main() {
  int n;
  long long factor;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (!i)
      factor = arr[i];
    else
      factor = gcd(arr[i], factor);
  }
  for (int i = 0; i < n; i++) {
    arr[i] /= factor;
    while (arr[i] % 2 == 0) arr[i] /= 2;
    while (arr[i] % 3 == 0) arr[i] /= 3;
    if (arr[i] != 1) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES");
  return 0;
}
