#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return (a) ? GCD(b % a, a) : b; }
long long LCM(long long a, long long b) { return a * b / GCD(a, b); }
long long fastpow(long long b, long long p) {
  if (!p) return 1;
  long long ret = fastpow(b, p >> 1);
  ret *= ret;
  if (p & 1) ret *= b;
  return ret;
}
string alpha = "abcdefghijklmnopqrstuvwxyz";
int divisor(int number) {
  int i;
  for (i = 2; i <= sqrt(number); i++) {
    if (number % i == 0) {
      return number / i;
    }
  }
  return 1;
}
int myXOR(int x, int y) {
  int res = 0;
  for (int i = 31; i >= 0; i--) {
    bool b1 = x & (1 << i);
    bool b2 = y & (1 << i);
    bool xoredBit = (b1 & b2) ? 0 : (b1 | b2);
    res <<= 1;
    res |= xoredBit;
  }
  return res;
}
void printDivisors(int n, vector<int>& v) {
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i && i > 1)
        v.push_back(i);
      else {
        if (i > 1) v.push_back(i);
        if (n / i > 1) v.push_back(n / i);
      }
    }
  }
}
int bin(vector<int> vec, int val) {
  int l = 0, r = vec.size() - 1, mid = r / 2;
  while (l <= r) {
    mid = (l + r) / 2;
    if (vec[mid] < val && vec[mid + 1] > val) {
      if (vec[mid + 1] == val) return mid + 1;
      return mid;
    } else if (vec[mid] > val) {
      r = mid - 1;
    } else if (vec[mid] < val) {
      l = mid + 1;
    } else if (vec[mid] == val)
      return mid;
  }
  return -1;
}
void clear(vector<bool> v) {
  for (int i = 0; i < v.size(); i++) v[i] = 0;
}
bool comp(const string& s1, const string& s2) { return s2 + s1 < s1 + s2; }
vector<string> split(const string& s, char delim) {
  vector<string> result;
  stringstream ss(s);
  string item;
  while (getline(ss, item, delim)) {
    result.push_back(item);
  }
  return result;
}
int countWords(string str) {
  stringstream s(str);
  string word;
  int count = 0;
  while (s >> word) count++;
  return count;
}
long long power(long long x, long long y, long long p, int& c) {
  int res = 1;
  if (x >= p) c++;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) {
      if (res * x >= p) c++;
      res = (res * x) % p;
    }
    y = y >> 1;
    if (x * x >= p) c++;
    x = (x * x) % p;
  }
  return res;
}
bool isPalindrome(string str) {
  int l = 0;
  int h = str.length() - 1;
  while (h > l) {
    if (str[l++] != str[h--]) {
      return 0;
    }
  }
  return 1;
}
bool checkMuns(vector<int> vec) {
  for (int i = 0; i < (int)(vec.size()); ++i) {
    if (vec[i] < 0) return 0;
  }
  return 1;
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long ceiLl(long long x, long long y) { return (x + y - 1) / y; }
vector<long long> divisors(long long n) {
  vector<long long> ans;
  long long i = 1;
  for (; i * i < n; i++) {
    if (n % i == 0) {
      ans.push_back(i);
      ans.push_back(n / i);
    }
  }
  if (i * i == n) ans.push_back(i);
  return ans;
}
vector<long long> findDivisors(long long n) {
  if (n == 1) return vector<long long>(1, 0);
  vector<long long> numFactors(n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j * i <= n; j++) numFactors[i * j]++;
  }
  return numFactors;
}
vector<long long> factorization(long long n) {
  vector<long long> primes;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      primes.push_back(i);
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n > 1) primes.push_back(n);
  return primes;
}
bool isSubSeq(string a, string b) {
  int idx = 0;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == b[idx]) idx++;
  }
  if (idx == b.length())
    return 1;
  else
    return 0;
}
bool isSubStr(string a, string b) {
  for (int i = 0; i < a.length(); i++) {
    if (a.substr(i, b.length()) == b) return 1;
  }
  return 0;
}
bool sortbysec(const pair<int, int>& a, const pair<int, int>& b) {
  return (a.second < b.second);
}
bool isEqual(string a, string b) {
  if (a.size() != b.size()) return 0;
  sort(((a).begin()), ((a).end()));
  sort(((b).begin()), ((b).end()));
  if (a == b) return 1;
  return 0;
}
string bin(unsigned n) {
  string ans = "";
  unsigned i;
  for (i = 1 << 14; i > 0; i = i / 2) (n & i) ? ans += '1' : ans += '0';
  return ans;
}
string leftrotate(string a, int d) {
  string s = a;
  reverse(s.begin(), s.begin() + d);
  reverse(s.begin() + d, s.end());
  reverse(s.begin(), s.end());
  return s;
}
string rightrotate(string a, int d) {
  string s = a;
  return leftrotate(s, s.length() - d);
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long findlcm(vector<long long> arr, int n) {
  long long ans = arr[0];
  for (int i = 1; i < n; i++) ans = (((arr[i] * ans)) / (gcd(arr[i], ans)));
  return ans;
}
long long findGCD(vector<long long> arr) {
  int n = arr.size();
  long long result = arr[0];
  for (int i = 1; i < n; i++) {
    result = gcd(arr[i], result);
    if (result == 1) {
      return 1;
    }
  }
  return result;
}
long long countDivisors(long long n) {
  long long cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;
      else
        cnt = cnt + 2;
    }
  }
  return cnt;
}
int main() {
  fast();
  int t;
  t = 1;
  map<long long, int> valid;
  int i = 0;
  while (1) {
    long long x = pow(2, i);
    if (x > 1000000000) break;
    valid[x] = 1;
    i++;
  }
  i = 0;
  while (1) {
    long long x = pow(3, i);
    if (x > 1000000000) break;
    valid[x] = 1;
    i++;
  }
  while (t--) {
    int n;
    cin >> n;
    vector<long long> vec(n);
    long long ma = 0;
    for (int i = 0; i < (int)(n); ++i) {
      cin >> vec[i];
      ma = max(ma, vec[i]);
    }
    for (int i = 0; i < (int)(n); ++i) {
      while (vec[i] % 2 == 0) {
        vec[i] /= 2;
      }
      while (vec[i] % 3 == 0) {
        vec[i] /= 3;
      }
    }
    set<int> s;
    for (int i = 0; i < (int)(n); ++i) s.insert(vec[i]);
    if (s.size() == 1)
      cout << "YES";
    else
      cout << "NO";
    cout << "\n";
  }
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are n players (including Limak himself) and right now all of them have bids on the table. i-th of them has bid with size ai dollars.

Each player can double his bid any number of times and triple his bid any number of times. The casino has a great jackpot for making all bids equal. Is it possible that Limak and his friends will win a jackpot?

Input

First line of input contains an integer n (2 ≤ n ≤ 105), the number of players.

The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 109) — the bids of players.

Output

Print "Yes" (without the quotes) if players can make their bids become equal, or "No" otherwise.

Examples

Input

4
75 150 75 50


Output

Yes


Input

3
100 150 250


Output

No

Note

In the first sample test first and third players should double their bids twice, second player should double his bid once and fourth player should both double and triple his bid.

It can be shown that in the second sample test there is no way to make all bids equal.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return (a) ? GCD(b % a, a) : b; }
long long LCM(long long a, long long b) { return a * b / GCD(a, b); }
long long fastpow(long long b, long long p) {
  if (!p) return 1;
  long long ret = fastpow(b, p >> 1);
  ret *= ret;
  if (p & 1) ret *= b;
  return ret;
}
string alpha = "abcdefghijklmnopqrstuvwxyz";
int divisor(int number) {
  int i;
  for (i = 2; i <= sqrt(number); i++) {
    if (number % i == 0) {
      return number / i;
    }
  }
  return 1;
}
int myXOR(int x, int y) {
  int res = 0;
  for (int i = 31; i >= 0; i--) {
    bool b1 = x & (1 << i);
    bool b2 = y & (1 << i);
    bool xoredBit = (b1 & b2) ? 0 : (b1 | b2);
    res <<= 1;
    res |= xoredBit;
  }
  return res;
}
void printDivisors(int n, vector<int>& v) {
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i && i > 1)
        v.push_back(i);
      else {
        if (i > 1) v.push_back(i);
        if (n / i > 1) v.push_back(n / i);
      }
    }
  }
}
int bin(vector<int> vec, int val) {
  int l = 0, r = vec.size() - 1, mid = r / 2;
  while (l <= r) {
    mid = (l + r) / 2;
    if (vec[mid] < val && vec[mid + 1] > val) {
      if (vec[mid + 1] == val) return mid + 1;
      return mid;
    } else if (vec[mid] > val) {
      r = mid - 1;
    } else if (vec[mid] < val) {
      l = mid + 1;
    } else if (vec[mid] == val)
      return mid;
  }
  return -1;
}
void clear(vector<bool> v) {
  for (int i = 0; i < v.size(); i++) v[i] = 0;
}
bool comp(const string& s1, const string& s2) { return s2 + s1 < s1 + s2; }
vector<string> split(const string& s, char delim) {
  vector<string> result;
  stringstream ss(s);
  string item;
  while (getline(ss, item, delim)) {
    result.push_back(item);
  }
  return result;
}
int countWords(string str) {
  stringstream s(str);
  string word;
  int count = 0;
  while (s >> word) count++;
  return count;
}
long long power(long long x, long long y, long long p, int& c) {
  int res = 1;
  if (x >= p) c++;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) {
      if (res * x >= p) c++;
      res = (res * x) % p;
    }
    y = y >> 1;
    if (x * x >= p) c++;
    x = (x * x) % p;
  }
  return res;
}
bool isPalindrome(string str) {
  int l = 0;
  int h = str.length() - 1;
  while (h > l) {
    if (str[l++] != str[h--]) {
      return 0;
    }
  }
  return 1;
}
bool checkMuns(vector<int> vec) {
  for (int i = 0; i < (int)(vec.size()); ++i) {
    if (vec[i] < 0) return 0;
  }
  return 1;
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long ceiLl(long long x, long long y) { return (x + y - 1) / y; }
vector<long long> divisors(long long n) {
  vector<long long> ans;
  long long i = 1;
  for (; i * i < n; i++) {
    if (n % i == 0) {
      ans.push_back(i);
      ans.push_back(n / i);
    }
  }
  if (i * i == n) ans.push_back(i);
  return ans;
}
vector<long long> findDivisors(long long n) {
  if (n == 1) return vector<long long>(1, 0);
  vector<long long> numFactors(n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j * i <= n; j++) numFactors[i * j]++;
  }
  return numFactors;
}
vector<long long> factorization(long long n) {
  vector<long long> primes;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      primes.push_back(i);
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n > 1) primes.push_back(n);
  return primes;
}
bool isSubSeq(string a, string b) {
  int idx = 0;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == b[idx]) idx++;
  }
  if (idx == b.length())
    return 1;
  else
    return 0;
}
bool isSubStr(string a, string b) {
  for (int i = 0; i < a.length(); i++) {
    if (a.substr(i, b.length()) == b) return 1;
  }
  return 0;
}
bool sortbysec(const pair<int, int>& a, const pair<int, int>& b) {
  return (a.second < b.second);
}
bool isEqual(string a, string b) {
  if (a.size() != b.size()) return 0;
  sort(((a).begin()), ((a).end()));
  sort(((b).begin()), ((b).end()));
  if (a == b) return 1;
  return 0;
}
string bin(unsigned n) {
  string ans = "";
  unsigned i;
  for (i = 1 << 14; i > 0; i = i / 2) (n & i) ? ans += '1' : ans += '0';
  return ans;
}
string leftrotate(string a, int d) {
  string s = a;
  reverse(s.begin(), s.begin() + d);
  reverse(s.begin() + d, s.end());
  reverse(s.begin(), s.end());
  return s;
}
string rightrotate(string a, int d) {
  string s = a;
  return leftrotate(s, s.length() - d);
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long findlcm(vector<long long> arr, int n) {
  long long ans = arr[0];
  for (int i = 1; i < n; i++) ans = (((arr[i] * ans)) / (gcd(arr[i], ans)));
  return ans;
}
long long findGCD(vector<long long> arr) {
  int n = arr.size();
  long long result = arr[0];
  for (int i = 1; i < n; i++) {
    result = gcd(arr[i], result);
    if (result == 1) {
      return 1;
    }
  }
  return result;
}
long long countDivisors(long long n) {
  long long cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;
      else
        cnt = cnt + 2;
    }
  }
  return cnt;
}
int main() {
  fast();
  int t;
  t = 1;
  map<long long, int> valid;
  int i = 0;
  while (1) {
    long long x = pow(2, i);
    if (x > 1000000000) break;
    valid[x] = 1;
    i++;
  }
  i = 0;
  while (1) {
    long long x = pow(3, i);
    if (x > 1000000000) break;
    valid[x] = 1;
    i++;
  }
  while (t--) {
    int n;
    cin >> n;
    vector<long long> vec(n);
    long long ma = 0;
    for (int i = 0; i < (int)(n); ++i) {
      cin >> vec[i];
      ma = max(ma, vec[i]);
    }
    for (int i = 0; i < (int)(n); ++i) {
      while (vec[i] % 2 == 0) {
        vec[i] /= 2;
      }
      while (vec[i] % 3 == 0) {
        vec[i] /= 3;
      }
    }
    set<int> s;
    for (int i = 0; i < (int)(n); ++i) s.insert(vec[i]);
    if (s.size() == 1)
      cout << "YES";
    else
      cout << "NO";
    cout << "\n";
  }
  return 0;
}

```