// Problem : A. Bear and Poker
// Contest : Codeforces - Codeforces Round #318 [RussianCodeCup Thanks-Round]
// (Div. 1) URL : https://codeforces.com/problemset/problem/573/A Memory Limit :
// 256 MB Time Limit : 2000 ms Powered by CP Editor
// (https://github.com/cpeditor/cpeditor)

/*
 * 竜
 * 平和な未来のために
 * あきらめないで
 */

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

// pairs
#define ff first
#define ss second

// vectors
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define tests\
int \
  t;           \
  cin >> t;    \
  while (t--)
// loops
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a)
#define trav(a, x) for (auto& a : x)

// constants
const int MOD = 1e9 + 7;  // 998244343;
const int MX = 1e6 + 4;
const ll INF = 1e18;  // not too close to LLONG_MAX
const ld PI = acos((ld)-1);
const int xd[4] = {1, 0, -1, 0},
          yd[4] = {0, 1, 0, -1};  // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

#define tcT template <class T
// ^ lol this makes everything look weird but I'll try it
tcT > using V = vector<T>;
tcT, size_t SZ > using AR = array<T, SZ>;

// helper funcs
tcT > T gcd(T& a, T& b) { return __gcd(a, b); }
tcT > T lcm(T& a, T& b) { return (a * b) / gcd(a, b); }
constexpr int pct(int x) { return __builtin_popcount(x); }  // # of bits set
constexpr int bits(int x) {
  return 31 - __builtin_clz(x);
}  // floor(log2(x)), change if 64
ll cdiv(ll a, ll b) {
  return a / b + ((a ^ b) > 0 && a % b);
}  // divide a by b rounded up
ll fdiv(ll a, ll b) {
  return a / b - ((a ^ b) < 0 && a % b);
}  // divide a by b rounded down
ll half(ll x) { return fdiv(x, 2); }

tcT > bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}  // set a = min(a,b)
tcT > bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

#define tcTU tcT, class U

tcTU > T fstTrue(T lo, T hi, U f) {
  // note: if (lo+hi)/2 is used instead of half(lo+hi)
  // then this will loop infinitely when lo=hi
  hi++;
  assert(lo <= hi);  // assuming f is increasing
  while (lo < hi) {  // find first index such that f is true
    T mid = half(lo + hi);
    f(mid) ? hi = mid : lo = mid + 1;
  }
  return lo;
}

tcTU > T lstTrue(T lo, T hi, U f) {
  lo--;
  assert(lo <= hi);  // assuming f is decreasing
  while (lo < hi) {  // find first index such that f is true
    T mid = half(lo + hi + 1);
    f(mid) ? lo = mid : hi = mid - 1;
  }
  return lo;
}

tcT > void remDup(vector<T>& v) {  // sort and remove duplicates
  sort(all(v));
  v.erase(unique(all(v)), end(v));
}

tcTU > void erase(T& t,
                  const U& u) {  // don't try to erase
  auto it = t.find(u);
  assert(it != end(t));
  t.erase(u);
}  // element that doesn't exist from (multi)set

// FILE I/O
void setIn(const str& s) { freopen(s.c_str(), "r", stdin); }

void setOut(const str& s) { freopen(s.c_str(), "w", stdout); }

void unsyncIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}

void setIO(str s = "") {
  unsyncIO();
  // cin.exceptions(cin.failbit);
  // throws exception when do smth illegal
  // ex. try to read letter into int
  if (sz(s)) {
    setIn(s + ".in"), setOut(s + ".out");
  }
}

void solve() {
  // がんばって
  int n;
  cin >> n;
  vl a(n);
  F0R(i, n) { cin >> a[i]; }
  unordered_set<int> us;
  F0R(i, n) {
    int val = a[i];
    while (val % 2 == 0 || val % 3 == 0) {
      if (val % 2 == 0)
        val /= 2;
      else
        val /= 3;
    }
    us.insert(val);
  }
  cout << (us.size() == 1 ? "Yes" : "No");
}

int main() {
  setIO();
  //    tests
  solve();
  return 0;
}


// Problem : A. Bear and Poker
// Contest : Codeforces - Codeforces Round #318 [RussianCodeCup Thanks-Round]
// (Div. 1) URL : https://codeforces.com/problemset/problem/573/A Memory Limit :
// 256 MB Time Limit : 2000 ms Powered by CP Editor
// (https://github.com/cpeditor/cpeditor)

/*
 * 竜
 * 平和な未来のために
 * あきらめないで
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

// pairs
#define ff first
#define ss second

// vectors
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define tests\
int \
  t;           \
  cin >> t;    \
  while (t--)
// loops
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a)
#define trav(a, x) for (auto& a : x)

// constants
const int MOD = 1e9 + 7;  // 998244343;
const int MX = 1e6 + 4;
const ll INF = 1e18;  // not too close to LLONG_MAX
const ld PI = acos((ld)-1);
const int xd[4] = {1, 0, -1, 0},
          yd[4] = {0, 1, 0, -1};  // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

#define tcT template <class T
// ^ lol this makes everything look weird but I'll try it
tcT > using V = vector<T>;
tcT, size_t SZ > using AR = array<T, SZ>;

// helper funcs
constexpr int pct(int x) { return __builtin_popcount(x); }  // # of bits set
constexpr int bits(int x) {
  return 31 - __builtin_clz(x);
}  // floor(log2(x)), change if 64
ll cdiv(ll a, ll b) {
  return a / b + ((a ^ b) > 0 && a % b);
}  // divide a by b rounded up
ll fdiv(ll a, ll b) {
  return a / b - ((a ^ b) < 0 && a % b);
}  // divide a by b rounded down
ll half(ll x) { return fdiv(x, 2); }

tcT > bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}  // set a = min(a,b)
tcT > bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

#define tcTU tcT, class U

tcTU > T fstTrue(T lo, T hi, U f) {
  // note: if (lo+hi)/2 is used instead of half(lo+hi)
  // then this will loop infinitely when lo=hi
  hi++;
  assert(lo <= hi);  // assuming f is increasing
  while (lo < hi) {  // find first index such that f is true
    T mid = half(lo + hi);
    f(mid) ? hi = mid : lo = mid + 1;
  }
  return lo;
}

tcTU > T lstTrue(T lo, T hi, U f) {
  lo--;
  assert(lo <= hi);  // assuming f is decreasing
  while (lo < hi) {  // find first index such that f is true
    T mid = half(lo + hi + 1);
    f(mid) ? lo = mid : hi = mid - 1;
  }
  return lo;
}

tcT > void remDup(vector<T>& v) {  // sort and remove duplicates
  sort(all(v));
  v.erase(unique(all(v)), end(v));
}

tcTU > void erase(T& t,
                  const U& u) {  // don't try to erase
  auto it = t.find(u);
  assert(it != end(t));
  t.erase(u);
}  // element that doesn't exist from (multi)set

// FILE I/O
void setIn(const str& s) { freopen(s.c_str(), "r", stdin); }

void setOut(const str& s) { freopen(s.c_str(), "w", stdout); }

void unsyncIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}

void setIO(str s = "") {
  unsyncIO();
  // cin.exceptions(cin.failbit);
  // throws exception when do smth illegal
  // ex. try to read letter into int
  if (sz(s)) {
    setIn(s + ".in"), setOut(s + ".out");
  }
}

void solve() {
  // がんばって
  int n;
  cin >> n;
  vi a(n);
  F0R(i, n)
  cin >> a[i];
  int mx = *max_element(all(a));
  bool sol = true;
  F0R(i, n) {
    if (mx % a[i]) {
      sol = false;
      break;
    }
  }
  cout << (sol ? "Yes" : "No");
}

int main() {
  setIO();
  //    tests
  solve();
  return 0;
}


  #include <bits/stdc++.h>
  #include <cstdio>
  #include <cstring>
  #include <cmath>
  #include <cstring>
  #include <chrono>
  #include <complex>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb emplace_back
  #define f first
  #define s second

  using namespace std;

    ll gcd( ll a, ll b )
    {
      if(b==0)
      {
           return a;
      }
      else
      {
           return gcd( b, a%b );
      }
    }
    ll lcm (ll a, ll b)
    {
      return (a*b)/gcd(a,b);
    }

  int main()
  {

  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif

    int n;

    cin>>n;

    int a[n];

    //int g=1;

    for(int i=0;i<n;i++) {
      cin>>a[i];
      //g=lcm(g,a[i]);
    }

    sort(a,a+n);

    int m=a[n-1];

    for(int i=0;i<n-1;i++) {
      float p=(float)a[n-1]/a[i];

     // cout<<p;
     //
      if(ceil(p)-floor(p)==1) {
        cout<<"NO";
        return 0;
      }

      else {
        int g=ceil(p);
      while(g%2==0||g%3==0) {
        if(g%2==0) {
          g=g/2;
        }

        else if(g%3==0) {
          g=g/3;
        }
      }

      if(g!=1) {
        cout<<"NO";
        return 0;
      }
      }

    }

    cout<<"YES";

    return 0;
  }


  #include <bits/stdc++.h>
  #include <cstdio>
  #include <cstring>
  #include <cmath>
  #include <cstring>
  #include <chrono>
  #include <complex>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb emplace_back
  #define f first
  #define s second

  using namespace std;

    ll gcd( ll a, ll b )
    {
      if(b==0)
      {
           return a;
      }
      else
      {
           return gcd( b, a%b );
      }
    }
    ll lcm (ll a, ll b)
    {
      return (a*b)/gcd(a,b);
    }

  int main()
  {

  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif

    int n;

    cin>>n;

    int a[n];

    int g=1;

    for(int i=0;i<n;i++) {
      cin>>a[i];
      g=lcm(g,a[i]);
    }

    sort(a,a+n);

    for(int i=0;i<n;i++) {
      int j=g/a[i];

      while(j%2==0||j%3==0) {
        if(j%2==0) {
          j=j/2;
        }

         if(j%3==0) {
          j=j/3;
        }
      }

      if(j>3) {
        cout<<"No";
        return 0;
      }

    }

    cout<<"Yes";

    return 0;
  }


  #include <bits/stdc++.h>
  #include <cstdio>
  #include <cstring>
  #include <cmath>
  #include <cstring>
  #include <chrono>
  #include <complex>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb emplace_back
  #define f first
  #define s second

  using namespace std;

    ll gcd( ll a, ll b )
    {
      if(b==0)
      {
           return a;
      }
      else
      {
           return gcd( b, a%b );
      }
    }
    ll lcm (ll a, ll b)
    {
      return (a*b)/gcd(a,b);
    }

  int main()
  {

  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif

    int n;

    cin>>n;

    int a[n];

    //int g=1;

    for(int i=0;i<n;i++) {
      cin>>a[i];
      //g=lcm(g,a[i]);
    }

    sort(a,a+n);

    int m=a[n-1];

    for(int i=0;i<n-1;i++) {
      for(int j=i+1;j<n;j++) {
        float p=(float)a[n-1]/a[i];

     // cout<<p;
     //
      if(ceil(p)-floor(p)==1) {
        cout<<"NO";
        return 0;
      }

      else {
        int g=ceil(p);
      while(g%2==0||g%3==0) {
        if(g%2==0) {
          g=g/2;
        }

        else if(g%3==0) {
          g=g/3;
        }
      }

      if(g!=1) {
        cout<<"NO";
        return 0;
      }
      }

      }

    }

    cout<<"YES";

    return 0;
  }


  #include <bits/stdc++.h>
  #include <cstdio>
  #include <cstring>
  #include <cmath>
  #include <cstring>
  #include <chrono>
  #include <complex>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb emplace_back
  #define f first
  #define s second

  using namespace std;

    ll gcd( ll a, ll b )
    {
      if(b==0)
      {
           return a;
      }
      else
      {
           return gcd( b, a%b );
      }
    }
    ll lcm (ll a, ll b)
    {
      return (a*b)/gcd(a,b);
    }

  int main()
  {

  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif

     int n;

     cin>>n;

     int a[n];

     int g=0;

     for(int i=0;i<n;i++) {
      cin>>a[i];
      g=gcd(g,a[i]);
     }

     for(int i=0;i<n;i++) {
      int j=a[i]/g;

      while(j%2==0||j%3==0) {
        if(j%2==0) {
          j=j/2;
        }

        else if(j%3==0) {
          j=j/3;
        }
      }

      if(j!=1) {
        cout<<"NO";
        return 0;
      }

     }

     cout<<"YES";

    return 0;
  }


  #include <bits/stdc++.h>
  #include <cstdio>
  #include <cstring>
  #include <cmath>
  #include <cstring>
  #include <chrono>
  #include <complex>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb emplace_back
  #define f first
  #define s second

  using namespace std;

    ll gcd( ll a, ll b )
    {
      if(b==0)
      {
           return a;
      }
      else
      {
           return gcd( b, a%b );
      }
    }
    ll lcm (ll a, ll b)
    {
      return (a*b)/gcd(a,b);
    }

  int main()
  {

  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif

    int n;

    cin>>n;

    int a[n];

    //int g=1;

    for(int i=0;i<n;i++) {
      cin>>a[i];
      //g=lcm(g,a[i]);
    }

    sort(a,a+n);

    int m=a[n-1];

    for(int i=0;i<n-1;i++) {
      for(int j=i+1;j<n;j++) {
        float p=(float)a[j]/a[i];

     // cout<<p;
     //
      if(ceil(p)-floor(p)==1) {
        cout<<"NO";
        return 0;
      }

      else {
        int g=ceil(p);
      while(g%2==0||g%3==0) {
        if(g%2==0) {
          g=g/2;
        }

        else if(g%3==0) {
          g=g/3;
        }
      }

      if(g!=1) {
        cout<<"NO";
        return 0;
      }
      }

      }

    }

    cout<<"YES";

    return 0;
  }


#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define F first

using namespace std;

const int N = 1e5 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;

int main(){
    int n;
    cin >> n;
    int arr[n];
    int gcd = 0;
    map < int , int > freq;
    for ( int i = 0; i < n ; ++i) {
        cin >> arr[i];
        if(arr[i] > 1 ) gcd = __gcd(arr[i], gcd);
        freq[arr[i]]++;
    }
    int gcds[n];
    for ( int i = 0; i < n ; ++i){
        gcds[i] = arr[i] / gcd;
    }
    if( freq[arr[0]] == n )
        return cout << "Yes", 0;
    for ( int i : gcds ){
        if ( arr[i] == 1 ) continue;
        if ( i%2 && i%3 )
            return cout << "No", 0;
    }
    cout << "Yes";
}


#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define F first

using namespace std;

const int N = 1e5 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;

int main(){
    int n;
    cin >> n;
    int arr[n];
    int gcd = 0;
    map < int , int > freq;
    for ( int i = 0; i < n ; ++i) {
        cin >> arr[i];
        if(arr[i] > 1 ) gcd = __gcd(arr[i], gcd);
        freq[arr[i]]++;
    }
    int gcds[n];
    for ( int i = 0; i < n ; ++i){
        gcds[i] = arr[i] / gcd;
    }
    if( freq[arr[0]] == n )
        return cout << "Yes", 0;
    for ( int i : gcds ){
//        cout << gcd << " " << i << endl;
        if ( arr[i] == 1 || i == 1) continue;
        if ( i%2 && i%3 )
            return cout << "No", 0;
    }
    cout << "Yes";
}


#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define F first

using namespace std;

const int N = 1e5 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;

int main(){
    int n;
    cin >> n;
    int arr[n];
    int gcd = 0;
    map < int , int > freq;
    for ( int i = 0; i < n ; ++i) {
        cin >> arr[i], gcd = __gcd(arr[i], gcd);
        freq[arr[i]]++;
    }
    int gcds[n];
    for ( int i = 0; i < n ; ++i){
        gcds[i] = arr[i] / gcd;
    }
    if( freq[arr[0]] == n )
        return cout << "Yes", 0;
    for ( int i : gcds ){
        if ( i%2 && i%3 )
            return cout << "No", 0;
    }
    cout << "Yes";
}


#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define F first

using namespace std;

const int N = 1e5 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;

int main(){
    int n;
    cin >> n;
    int arr[n];
    int gcd = 0;
    for ( int i = 0; i < n ; ++i) cin >> arr[i], gcd = __gcd(arr[i], gcd);
    int gcds[n];
    for ( int i = 0; i < n ; ++i){
        gcds[i] = arr[i] / gcd;
    }
    for ( int i : gcds ){
        if ( i%2 && i%3 )
            return cout << "No", 0;
    }
    cout << "Yes";
}


#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define F first

using namespace std;

const int N = 1e5 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;

int main(){
    int n;
    cin >> n;
    int arr[n];
    int gcd = 0;
    map < int , int > freq;
    for ( int i = 0; i < n ; ++i) {
        cin >> arr[i], gcd = __gcd(arr[i], gcd);
        freq[arr[i]]++;
    }
    int gcds[n];
    for ( int i = 0; i < n ; ++i){
        gcds[i] = arr[i] / gcd;
    }
    if( freq[arr[0]] == n )
        return cout << "Yes", 0;
    for ( int i : gcds ){
        if ( i == 1 ) continue;
        if ( i%2 && i%3 )
            return cout << "No", 0;
    }
    cout << "Yes";
}


#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define F first

using namespace std;

const int N = 2e5 + 9, M = 1e9 + 9, OO = 0x3f3f3f3f;

int n, tmp, rem = OO;

int main()
{
    cin >> n;
    while(n--){
        cin >> tmp;
        while(!(tmp%2)) tmp/=2;
        while(!(tmp%3)) tmp/=3;
//        cout << tmp << " " ;
        if(rem == OO) rem = tmp;
        else if(rem != tmp) return cout <<"No", 0;

    }
    cout << "Yes";
}


#include <bits/stdc++.h>
using namespace std;
#define int64 long long int

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T=1;
	//cin>>T;
	while(T--)
	{
		int64 n,i;
		cin>>n;
		int64 a[n];
		int64 g;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		g=a[0];
		for(i=1;i<n;i++)
		{
			g=__gcd(a[i],g);
		}
		bool b=true;
		for(i=0;i<n;i++)
		{
			a[i]/=g;
			while(a[i]%2==0)
			{
				a[i]/=2;
			}
			while(a[i]%3==0)
			{
				a[i]/=3;
			}
			if(a[i]!=1)
				b=false;
		}
		if(b)
			cout<<"Yes";
		else
			cout<<"No";

	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int64 long long int

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T=1;
	//cin>>T;
	while(T--)
	{
		int64 n,i;
		cin>>n;
		vector<int64> a(n);
		int64 g;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		g=a[0];
		for(i=1;i<n;i++)
		{
			g=__gcd(a[i],g);
		}
		bool b=true;
		for(i=0;i<n;i++)
		{
			a[i]/=g;
			while(a[i]%2==0)
			{
				a[i]/=2;
			}
			while(a[i]%3==0)
			{
				a[i]/=3;
			}
			if(a[i]!=1)
				b=false;
		}
		if(b)
			cout<<"Yes";
		else
			cout<<"No";

	}

	return 0;
}


/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()

typedef long int int32;
typedef unsigned long int uint32;
typedef pair<int32,int32> PII32;
typedef vector<int32> VI32;
typedef vector<PII32> VII32;
typedef pair<int,int> PII;
typedef long long int int64;
typedef unsigned long long int uint64;
typedef pair<int64,int64> PII64;
typedef vector<int64> VI64;
typedef vector<PII64> VII64;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<vector<int>> VVI;

void fastio()
{
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);

    	freopen("output.txt", "w", stdout);
	#endif

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main()
{
	fastio();
	int T=1;
	//cin>>T;
	while(T--)
	{
		int64 n,i;
		cin>>n;
		int64 a[n];
		int64 g;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		g=a[0];
		for(i=1;i<n;i++)
		{
			g=__gcd(a[i],g);
		}
		bool b=true;
		for(i=0;i<n&&b;i++)
		{
			a[i]/=g;
			while(a[i]%2==0)
			{
				a[i]/=2;
			}
			while(a[i]%3==0)
			{
				a[i]/=3;
			}
			if(a[i]!=1)
				b=false;
		}
		if(b)
			cout<<"Yes\n";
		else
			cout<<"No\n";

	}

	return 0;
}


/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()

typedef long int int32;
typedef unsigned long int uint32;
typedef pair<int32,int32> PII32;
typedef vector<int32> VI32;
typedef vector<PII32> VII32;
typedef pair<int,int> PII;
typedef long long int int64;
typedef unsigned long long int uint64;
typedef pair<int64,int64> PII64;
typedef vector<int64> VI64;
typedef vector<PII64> VII64;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<vector<int>> VVI;

void fastio()
{

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main()
{
	fastio();
	int T=1;
	//cin>>T;
	while(T--)
	{
		int64 n,i;
		cin>>n;
		int64 a[n];
		int64 g;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		g=a[0];
		for(i=1;i<n;i++)
		{
			g=__gcd(a[i],g);
		}
		bool b=true;
		for(i=0;i<n;i++)
		{
			a[i]/=g;
			while(a[i]%2==0)
			{
				a[i]/=2;
			}
			while(a[i]%3==0)
			{
				a[i]/=3;
			}
			if(a[i]!=1)
				b=false;
		}
		if(b)
			cout<<"Yes";
		else
			cout<<"No";

	}

	return 0;
}


/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()

typedef long int int32;
typedef unsigned long int uint32;
typedef pair<int32,int32> PII32;
typedef vector<int32> VI32;
typedef vector<PII32> VII32;
typedef pair<int,int> PII;
typedef long long int int64;
typedef unsigned long long int uint64;
typedef pair<int64,int64> PII64;
typedef vector<int64> VI64;
typedef vector<PII64> VII64;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<vector<int>> VVI;

void fastio()
{
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);

    	freopen("output.txt", "w", stdout);
	#endif

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main()
{
	fastio();
	int T=1;
	//cin>>T;
	while(T--)
	{
		int64 n,i;
		cin>>n;
		int64 a[n];
		int64 g;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
			while(a[i]%2==0)
			{
				a[i]/=2;
			}
			while(a[i]%3==0)
			{
				a[i]/=3;
			}
		}
	/*	g=a[0];
		for(i=1;i<n;i++)
		{
			g=__gcd(a[i],g);
		}*/
		bool b=true;
		for(i=0;i<n-1&&b;i++)
		{

			if(a[i]!=a[i+1])
				b=false;
		}
		if(b)
			cout<<"Yes\n";
		else
			cout<<"No\n";

	}

	return 0;
}


/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()

typedef long int int32;
typedef unsigned long int uint32;
typedef pair<int32,int32> PII32;
typedef vector<int32> VI32;
typedef vector<PII32> VII32;
typedef pair<int,int> PII;
typedef long long int int64;
typedef unsigned long long int uint64;
typedef pair<int64,int64> PII64;
typedef vector<int64> VI64;
typedef vector<PII64> VII64;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<vector<int>> VVI;

void fastio()
{
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);

    	freopen("output.txt", "w", stdout);
	#endif

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main()
{
	fastio();
	int T=1;
	//cin>>T;
	while(T--)
	{
		int64 n,i;
		cin>>n;
		int64 a[n];
		int64 g;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		g=a[0];
		for(i=1;i<n;i++)
		{
			g=__gcd(a[i],g);
		}
		bool b=true;
		for(i=0;i<n;i++)
		{
			a[i]/=g;
			while(a[i]%2==0)
			{
				a[i]/=2;
			}
			while(a[i]%3==0)
			{
				a[i]/=3;
			}
			if(a[i]!=1)
				b=false;
		}
		if(b)
			cout<<"Yes\n";
		else
			cout<<"No\n";

	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int64 long long int

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
		int64 n,i;
		cin>>n;
		vector<int64> a(n);
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		int64 g=a[0];
		for(i=0;i<n;i++)
		{
			g=__gcd(a[i],g);
		}
		bool b=true;
		for(i=0;i<n;i++)
		{
			int64 t=a[i]/g;
			while(t%2==0)
			{
				t/=2;
			}
			while(t%3==0)
			{
				t/=3;
			}
			if(t!=1)
				b=false;
		}
		if(b)
			cout<<"Yes";
		else
			cout<<"No";

	return 0;
}


//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main()
{
  ull n;
  scanf("%llu",&n);
  set<ull>a;
  vector<ull>b;
  ull i,j;
  for(i=0;i<n;i++)
  {
      scanf("%llu",&j);
      a.insert(j);
  }
  ull lc=1;
  set<ull>::iterator it=a.begin();

  for(it=a.begin();it!=a.end();it++)
  {
      j=*it;
      lc=(j*lc)/(__gcd(j,lc));
  }
  for(it=a.begin();it!=a.end();it++)
  {
      j=*it;
      b.push_back(lc/j);
  }
  int flag=0;
  for(i=0;i<b.size();i++)
  {
      while(b[i]%6==0)
      {
          b[i]/=6;
      }
      while(b[i]%2==0)
      {
          b[i]/=2;
      }
      while(b[i]%3==0)
      {
          b[i]/=3;
      }
      if(b[i]!=1)
      {
          flag=1;
          break;
      }
  }
  if(flag==0)
  {
      printf("YES");
  }
  else
  {
      printf("NO");
  }
  return 0;
}


//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main()
{
  ull n;
  scanf("%llu",&n);
  vector<ull>a(n);
  vector<ull>b(n);
  ull i;
  for(i=0;i<n;i++)
  {
      scanf("%llu",&a[i]);
  }
  sort(a.begin(),a.end());
  ull lc=1;
  for(i=0;i<n;i++)
  {
      lc=(a[i]*lc)/(__gcd(a[i],lc));
  }
  for(i=0;i<n;i++)
  {
      b[i]=lc/a[i];
  }
  int flag=0;
  for(i=0;i<n;i++)
  {
      while(b[i]%6==0)
      {
          b[i]/=6;
      }
      while(b[i]%2==0)
      {
          b[i]/=2;
      }
      while(b[i]%3==0)
      {
          b[i]/=3;
      }
      if(b[i]!=1)
      {
          flag=1;
          break;
      }
  }
  if(flag==0)
  {
      printf("YES");
  }
  else
  {
      printf("NO");
  }
  return 0;
}


//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  scanf("%lld",&n);
  vector<ll>a(n);
  vector<ll>b(n);
  ll i;
  for(i=0;i<n;i++)
  {
      scanf("%lld",&a[i]);
  }
  sort(a.begin(),a.end());
  ll lc=1;
  for(i=0;i<n;i++)
  {
      lc=(a[i]*lc)/(__gcd(a[i],lc));
  }
  for(i=0;i<n;i++)
  {
      b[i]=lc/a[i];
  }
  int flag=0;
  for(i=0;i<n;i++)
  {
      while(b[i]%6==0)
      {
          b[i]/=6;
      }
      while(b[i]%2==0)
      {
          b[i]/=2;
      }
      while(b[i]%3==0)
      {
          b[i]/=3;
      }
      if(b[i]!=1)
      {
          flag=1;
          break;
      }
  }
  if(flag==0)
  {
      printf("YES");
  }
  else
  {
      printf("NO");
  }
  return 0;
}


//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  scanf("%lld",&n);
  vector<ll>a(n);
  ll i,flag=0;
  for(i=0;i<n;i++)
  {
      scanf("%lld",&a[i]);
      while(a[i]%6==0)
      {
          a[i]/=6;
      }
      while(a[i]%3==0)
      {
          a[i]/=3;
      }
      while(a[i]%2==0)
      {
          a[i]/=2;
      }
      if((i>=1)&&(a[i]!=a[i-1]))
      {
          flag=1;
      }

  }
  if(flag==1)
  {
      printf("No");
  }
  else
  {
      printf("Yes");
  }
  return 0;
}


//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  scanf("%lld",&n);
  vector<ll>a(n);
  vector<ll>b(n);
  ll i;
  for(i=0;i<n;i++)
  {
      scanf("%lld",&a[i]);
  }
  sort(a.begin(),a.end());
  ll lc=1;
  for(i=0;i<n;i++)
  {
      lc=(a[i]*lc)/(__gcd(a[i],lc));
  }
  for(i=0;i<n;i++)
  {
      b[i]=lc/a[i];
  }
  int flag=0;
  for(i=0;i<n;i++)
  {
      while(b[i]%2==0)
      {
          b[i]/=2;
      }
      while(b[i]%3==0)
      {
          b[i]/=3;
      }
      if(b[i]!=1)
      {
          flag=1;
          break;
      }
  }
  if(flag==0)
  {
      printf("YES");
  }
  else
  {
      printf("NO");
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
long int check(long int num)
{
    if(num%2==0 || num%3==0)
    return 0;
    else
    return 1;
}
long int gcd(long int a,long int b)
{
     if (a == 0)
       return b;
    if (b == 0)
       return a;

    // base case
    if (a == b)
        return a;

    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
int main()
{
    int n;
    cin>>n;
    long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long int z=a[0];
    int flag=0;
    for(int i=1;i<n;i++)
    {
        z=gcd(z,a[i]);
    }
    //cout<<z;
    for(int i=0;i<n;i++)
    {
        if(check(a[i]/z))
        {
            flag=1;
            break;
        }
    }
    if(flag)
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long int check(long int num)
{
    if(num==1);
    return 0;

    if(num%2==0 || num%3==0)
    return 0;
    else
    return 1;
}
long int gcd(long int a,long int b)
{
     if (a == 0)
       return b;
    if (b == 0)
       return a;

    // base case
    if (a == b)
        return a;

    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
int main()
{
    int n;
    cin>>n;
    long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long int z=a[0];
    int flag=0;
    for(int i=1;i<n;i++)
    {
        z=gcd(z,a[i]);
    }
    //cout<<z;
    for(int i=0;i<n;i++)
    {
        if(check(a[i]/z))
        {
            flag=1;
            break;
        }
    }
    if(flag)
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long int gcd(long int a,long int b)
{
     if (a == 0)
       return b;
    if (b == 0)
       return a;

    // base case
    if (a == b)
        return a;

    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
int main()
{
    int n;
    cin>>n;
    long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long int z=a[0];
    int flag=0;
    for(int i=0;i<n;i++)
    {
        z=gcd(z,a[i]);
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]/z !=2 || a[i]/z != 3)
        {
            flag=1;
            break;
        }
    }
    if(flag)
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long  a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long z=a[0];
    int flag=0;
    // for(int i=1;i<n;i++)
    // {
    //     z=gcd(z,a[i]);
    // }
    //cout<<z;
    for(int i=0;i<n;i++)
    {
        while(a[i] % 2 == 0)
            a[i] = a[i] / 2;
        while(a[i] % 3 == 0)
            a[i] = a[i] / 3;
    }
    for(int i = 0;i < n - 1;i++)
        if(a[i] != a[i + 1])
        {
            printf("NO\n");
            return 0;
        }
    printf("YES\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long int gcd(long int a,long int b)
{
     if (a == 0)
       return b;
    if (b == 0)
       return a;

    // base case
    if (a == b)
        return a;

    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
long int lcm(long int arr[],int n)
{
    long int ans = arr[0];
    for (int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
int main()
{
    int n;
    cin>>n;
    long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long int z=a[0];
    int flag=0;
    for(int i=1;i<n;i++)
    {
        z=gcd(z,a[i]);
    }
    //cout<<z;
    for(int i=0;i<n;i++)
    {
        if(z==1)
        break;
        while(a[i]>0)
        {
        a[i]/=z;
        if(a[i]<z)
        break;
        }
    }
    long int z1=lcm(a,n);
    if(z1==6)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long int check(long int num)
{
    if num==1;
    return 0;

    if(num%2==0 || num%3==0)
    return 0;
    else
    return 1;
}
long int gcd(long int a,long int b)
{
     if (a == 0)
       return b;
    if (b == 0)
       return a;

    // base case
    if (a == b)
        return a;

    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
int main()
{
    int n;
    cin>>n;
    long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long int z=a[0];
    int flag=0;
    for(int i=1;i<n;i++)
    {
        z=gcd(z,a[i]);
    }
    //cout<<z;
    for(int i=0;i<n;i++)
    {
        if(check(a[i]/z))
        {
            flag=1;
            break;
        }
    }
    if(flag)
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long int gcd(long int a,long int b)
{
     if (a == 0)
       return b;
    if (b == 0)
       return a;

    // base case
    if (a == b)
        return a;

    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
long int lcm(long int arr[],int n)
{
    long int ans = arr[0];
    for (int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
int main()
{
    int n;
    cin>>n;
    long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long int z=a[0];
    int flag=0;
    for(int i=1;i<n;i++)
    {
        z=gcd(z,a[i]);
    }
    //cout<<z;
    for(int i=0;i<n;i++)
    {
        if(z==1)
        break;
        while(a[i]>0)
        {
        a[i]/=z;
        if(a[i]<z)
        break;
        }
    }
    long int z1=lcm(a,n);
    if(z1==2 || z1==3 || z1==6)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long int check(long int num)
{
    if(num==1)
    return 0;

    if(num%2==0 || num%3==0)
    return 0;
    else
    return 1;
}
long int gcd(long int a,long int b)
{
     if (a == 0)
       return b;
    if (b == 0)
       return a;

    // base case
    if (a == b)
        return a;

    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
int main()
{
    int n;
    cin>>n;
    long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long int z=a[0];
    int flag=0;
    for(int i=1;i<n;i++)
    {
        z=gcd(z,a[i]);
    }
    //cout<<z;
    for(int i=0;i<n;i++)
    {
        if(check(a[i]/z))
        {
            flag=1;
            break;
        }
    }
    if(flag)
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
int main()
{
   speed;
   int n,flg=0;
   cin>>n;
   long long int a[n],mx=0,x,y;
   for(int i=0;i<n;i++)
   { cin>>a[i];
     mx=max(mx,a[i]);
   }
   mx=mx*2;
   stack<long long int>st;
   for(int i=0;i<n;i++)
   {
        x=a[i];
        flg=0;
        st.clear();
        st.push(x);
        while(!st.empty())
        {
            x=st.top();
            st.pop();
            if(x==mx)
            {
                flg=1;
                break;
            }
            y=x*2;
            if(y<=mx)
            {
                st.push(y);
            }

            y=x*3;
            if(y<=mx)
            {
                st.push(y);
            }

        }
        if(flg==0)
        {
            flg=2;
            break;
        }

   }
   if(flg==2)
   cout<<"NO"<<endl;
   else
   cout<<"YES\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
int main()
{
   speed;
   int n,flg=0;
   cin>>n;
   long long int a[n],mx=0,x,y;
   for(int i=0;i<n;i++)
   { cin>>a[i];
     mx=max(mx,a[i]);
   }
   mx=mx*2;

   for(int i=0;i<n;i++)
   {
        x=a[i];
        flg=0;
          stack<long long int>st;
        st.push(x);
        while(!st.empty())
        {
            x=st.top();
            st.pop();
            if(x==mx)
            {
                flg=1;
                break;
            }
            y=x*2;
            if(y<=mx)
            {
                st.push(y);
            }

            y=x*3;
            if(y<=mx)
            {
                st.push(y);
            }

        }
        if(flg==0)
        {
            flg=2;
            break;
        }

   }
   if(flg==2)
   cout<<"NO"<<endl;
   else
   cout<<"YES\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
int main()
{
   speed;
   int n,flg=0;
   cin>>n;
   long long int a[n],mx=0,x,y;
   for(int i=0;i<n;i++)
   { cin>>a[i];
     mx=max(mx,a[i]);
   }
   mx=mx*2;
   stack<long long int>st;
   for(int i=0;i<n;i++)
   {
        x=a[i];
        flg=0;
        st.push(x);
        while(!st.empty())
        {
            x=st.top();
            st.pop();
            if(x==mx)
            {
                flg=1;
                break;
            }
            y=x*2;
            if(y<=mx)
            {
                st.push(y);
            }

            y=x*3;
            if(y<=mx)
            {
                st.push(y);
            }

        }
        if(flg==0)
        {
            flg=2;
            break;
        }

   }
   if(flg==2)
   cout<<"NO"<<endl;
   else
   cout<<"YES\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
int main()
{
   speed;
   int n,flg=0;
   cin>>n;
   long int a[n],mx=0,x,y;
   for(int i=0;i<n;i++)
   { cin>>a[i];
     mx=max(mx,a[i]);
   }
   mx=mx*2;
   stack<long int>st;
   for(int i=0;i<n;i++)
   {
        x=a[i];
        flg=0;
        st.push(x);
        while(!st.empty())
        {
            x=st.top();
            st.pop();
            if(x==mx)
            {
                flg=1;
                break;
            }
            y=x*2;
            if(y<=mx)
            {
                st.push(y);
            }

            y=x*3;
            if(y<=mx)
            {
                st.push(y);
            }

        }
        if(flg==0)
        {
            flg=2;
            break;
        }

   }
   if(flg==2)
   cout<<"NO"<<endl;
   else
   cout<<"YES\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
int main()
{
   speed;
   int n,flg=0;
   cin>>n;
   long long int a[n],mx=0,x,y;
   for(int i=0;i<n;i++)
   cin>>a[i];

     for(int i=0;i<n;i++)
     {
         while(a[i]%2==0)a[i]=a[i]/2;
         while(a[i]%3==0) a[i]=a[i]/3;
     }
     for(int i=1;i<n;i++)
     {
         if(a[i]!=a[0])
         {
             cout<<"NO"<<endl;
             return 0;
         }
     }

  cout<<"YES"<<endl;
	return 0;
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x=0,j,y,z,k,n;

cin>>n;
	set<ll> a,b;
	rep(i,0,n,1){	cin>>x;
		while(x%6)	x=x/6;
		while(x%2)	x=x/2;
		while(x%3)	x=x/3;
		a.insert(x);
		// ce(x)
	}
	for(auto x:a){
		while(x%6)	x=x/6;
		while(x%2)	x=x/2;
		while(x%3)	x=x/3;
		b.insert(x);
	}
	n=b.size();

	string s="No";
	if(n==1)	s="Yes";
	ce(s)
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x=0,j,y,z,k,n;

cin>>n;
	set<ll> a,b;
	rep(i,0,n,1){	cin>>x;
		a.insert(x);
	}
	for(auto zx:a){
		x=zx;
		while(x%144==0)	x=x/144;
		while(x%72==0)	x=x/72;
		while(x%54==0)	x=x/54;
		while(x%36==0)	x=x/36;
		while(x%24==0)	x=x/24;
		while(x%12==0)	x=x/12;
		while(x%6==0)	x=x/6;
		while(x%2==0)	x=x/2;
		while(x%3==0)	x=x/3;
		// ce(x)
		b.insert(x);
	}
	n=b.size();
	// ce(n)
	string s="No";
	if(n==1)	s="Yes";
	ce(s)
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x=0,j,y,z,k,n;

cin>>n;
	set<ll> a,b;
	rep(i,0,n,1){	cin>>x;
		a.insert(x);
	}
	for(auto zx:a){
		x=zx;
		// cout<<x<<" ";
		while(x%72==0)	x=x/72;
		while(x%60==0)	x=x/60;
		while(x%24==0)	x=x/24;
		while(x%12==0)	x=x/12;
		while(x%6==0)	x=x/6;
		while(x%2==0)	x=x/2;
		while(x%3==0)	x=x/3;
		// ce(x)
		b.insert(x);
	}
	n=b.size();
	// ce(n)
	string s="No";
	if(n==1)	s="Yes";
	ce(s)
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x=0,j,y,z,k,n;

cin>>n;
	ll a[n];
	rep(i,0,n,1)	cin>>a[i];
	sort(a,a+n);
	rep(i,0,n,1)	x=__gcd(x,a[i]);
	string s="No";
	if(x%2&&x%3)	s="Yes";
	ce(s)
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x=0,j,y,z,k,n;

cin>>n;
	set<ll> a,b;
	rep(i,0,n,1){	cin>>x;
		a.insert(x);
	}
	for(auto zx:a){
		x=zx;
		// cout<<x<<" ";
		while(x%6==0)	x=x/6;
		while(x%2==0)	x=x/2;
		while(x%3==0)	x=x/3;
		// ce(x)
		b.insert(x);
	}
	n=b.size();
	// ce(n)
	string s="No";
	if(n==1)	s="Yes";
	ce(s)
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x=0,j,y,z,k,n;

cin>>n;
	set<ll> a,b;
	rep(i,0,n,1){	cin>>x;
		a.insert(x);
	}
	for(auto zx:a){
		x=zx;
		// cout<<x<<" ";
		while(x%144==0)	x=x/144;
		while(x%72==0)	x=x/72;
		while(x%36==0)	x=x/36;
		while(x%24==0)	x=x/24;
		while(x%12==0)	x=x/12;
		while(x%6==0)	x=x/6;
		while(x%2==0)	x=x/2;
		while(x%3==0)	x=x/3;
		// ce(x)
		b.insert(x);
	}
	n=b.size();
	// ce(n)
	string s="No";
	if(n==1)	s="Yes";
	ce(s)
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x=0,j,y,z,k,n;

cin>>n;
	set<ll> a,b;
	rep(i,0,n,1){	cin>>x;
		while(x%6)	x=x/6;
		while(x%2)	x=x/2;
		while(x%3)	x=x/3;
		a.insert(x);
		ce(x)
	}
	// unique_sort(a);
	// x=0;
	n=a.size();
	// ce(n)
	// rep(i,0,n,1)	x=__gcd(x,a[i]);

	string s="No";
	if(n==1)	s="Yes";
	ce(s)
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x=0,j,y,z,k,n;

cin>>n;
	set<ll> a,b;
	rep(i,0,n,1){	cin>>x;
		while(x%6)	x=x/6;
		while(x%2)	x=x/2;
		while(x%3)	x=x/3;
		a.insert(x);
		// ce(x)
	}
	// unique_sort(a);
	// x=0;
	n=a.size();
	// ce(n)
	// rep(i,0,n,1)	x=__gcd(x,a[i]);

	string s="No";
	if(n==1)	s="Yes";
	ce(s)
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[1000100];
long long int n, a, b;

int main()
{
	cin >> n;
	for (long long int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	bool ez = false;

	for (long long int i = 0; i < n; i++)
	{
		b = max(b, M[i]);
	}

	for (long long int i = 0; i < n; i++)
	{
		if (b % M[i] == 0)
		{
			a = b / M[i];
			while (a % 3 == 0)
			{
				a /= 3;
			}
			while (a % 2 == 0)
			{
				a /= 2;
			}
			if (a == 1)
			{
				cout << "YES";
			}
			else
				cout << "NO";
			return 0;
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[100010];
long long int n, a;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	sort(M, M + n);

	bool ez = true;

	for (int i = n-1; i >= 0; i--)
	{
		if (M[n-1] % M[i] == 0)
		{
			a = M[n - 1] / M[i];
			while (a != 1)
			{
				if (a % 2 == 0)
				{
					a /= 2;
				}
				else if (a % 3 == 0)
				{
					a /= 3;
				}
				if(a % 2 != 0 && a % 3 != 0 && a > 2)
				{
					ez = false;
					cout << "NO";
					return 0;
				}
			}
			ez = true;
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}
	if (ez)
	{
		cout << "YES";
	}
	else
		cout << "NO";
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[1000100];
long long int n, a, b;

int main()
{
	cin >> n;
	for (long long int i = 0; i < n; i++)
	{
		cin >> M[i];

		while (M[i] % 3 == 0)
		{
			M[i] /= 3;
		}
		while (M[i] % 2 == 0)
		{
			M[i] /= 2;
		}

	}

	for (long long int i = 0; i < n - 1; i++)
	{
		if (M[i] != M[i + 1])
		{
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[1000100];
long long int n, a, b;

int main()
{
	cin >> n;
	for (long long int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	if (n == 1)
	{
		cout << "NO";
		return 0;
	}

	bool ez = false;

	for (long long int i = 0; i < n; i++)
	{
		b = max(b, M[i]);
	}

	for (long long int i = 0; i < n; i++)
	{
		if (b % M[i] == 0)
		{
			a = b / M[i];
			while (a != 1)
			{
				if (a % 2 == 0)
				{
					a /= 2;
				}
				else if (a % 3 == 0)
				{
					a /= 3;
				}
				if (a % 2 != 0 && a % 3 != 0 && a > 2)
				{
					ez = false;
					cout << "NO";
					return 0;
				}
			}
			if (a == 1)
			{
				ez = true;
			}
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}
	if (ez)
	{
		cout << "YES";
	}
	else
		cout << "NO";
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[100010];
long long int n, a;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	sort(M, M + n);

	bool ez = true;

	for (int i = n-1; i > 0; i--)
	{
		if (M[n-1] % M[i] == 0)
		{
			a = M[n - 1] / M[i];
			while (a != 1)
			{
				if (a % 2 == 0)
				{
					a /= 2;
				}
				else if (a % 3 == 0)
				{
					a /= 3;
				}
				if(a % 2 != 0 && a % 3 != 0 && a > 2)
				{
					ez = false;
					cout << "NO";
					return 0;
				}
			}
			ez = true;
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}
	if (ez)
	{
		cout << "YES";
	}
	else
		cout << "NO";
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[1000100];
long long int n, a, b;

int main()
{
	cin >> n;
	for (long long int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	if (n == 1)
	{
		cout << "NO";
		return 0;
	}

	bool ez = false;

	for (long long int i = 0; i < n; i++)
	{
		b = max(b, M[i]);
	}

	for (long long int i = 0; i < n; i++)
	{
		if (b % M[i] == 0)
		{
			a = b / M[i];
			while (a != 1)
			{
				if (a % 2 == 0)
				{
					a /= 2;
				}
				else if (a % 3 == 0)
				{
					a /= 3;
				}
				if (a % 2 != 0 && a % 3 != 0 && a > 2)
				{
					ez = false;
					cout << "NO";
					return 0;
				}
			}
			if (a == 1)
			{
				ez = true;
			}
			else
				cout << "NO";
			return 0;
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}
	if (ez)
	{
		cout << "YES";
	}
	else
		cout << "NO";
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[100010];
long long int n, a;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	sort(M, M + n);

	bool ez = false;

	for (int i = n-1; i >= 0; i--)
	{
		if (M[n - 1] % M[i] == 0)
		{
			a = M[n - 1] / M[i];
			while (a != 1)
			{
				if (a % 2 == 0)
				{
					a /= 2;
				}
				else if (a % 3 == 0)
				{
					a /= 3;
				}
				if (a % 2 != 0 && a % 3 != 0 && a > 2)
				{
					ez = false;
					cout << "NO";
					return 0;
				}
			}
			if (a == 1)
			{
				ez = true;
			}
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}
	if (ez)
	{
		cout << "YES";
	}
	else
		cout << "NO";
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[100010];
long long int n, a;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	sort(M, M + n);

	bool ez = true;

	for (int i = n-1; i > 0; i--)
	{
		if (M[n-1] % M[i] == 0)
		{
			a = M[n - 1] / M[i];
			while (a != 3 && a != 2)
			{
				if (a % 2 == 0)
				{
					a /= 2;
				}
				else if (a % 3 == 0)
				{
					a /= 2;
				}
				if(a % 2 != 0 && a % 3 != 0)
				{
					ez = false;
					cout << "NO";
					return 0;
				}
			}
			ez = true;
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}
	if (ez)
	{
		cout << "YES";
	}
	else
		cout << "NO";
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[1000100];
long long int n, a, b;

int main()
{
	cin >> n;
	for (long long int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	bool ez = false;

	for (long long int i = 0; i < n; i++)
	{
		b = max(b, M[i]);
	}

	for (long long int i = 0; i < n; i++)
	{
		if (b % M[i] == 0)
		{
			a = b / M[i];
			while (a != 1)
			{
				if (a % 2 == 0)
				{
					a /= 2;
				}
				else if (a % 3 == 0)
				{
					a /= 3;
				}
				else
				{
					ez = false;
					cout << "NO";
					return 0;
				}
			}
			ez = true;
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}
	if (ez)
	{
		cout << "YES";
	}
	else
		cout << "NO";
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[100010];
long long int n, a, b;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	if (n == 1)
	{
		cout << "NO";
		return 0;
	}

	bool ez = false;

	for (int i = 0; i < n; i++)
	{
		b = max(b, M[i]);
	}

	for (int i = 0; i < n; i++)
	{
		if (b % M[i] == 0)
		{
			a = b / M[i];
			while (a != 1)
			{
				if (a % 2 == 0)
				{
					a /= 2;
				}
				else if (a % 3 == 0)
				{
					a /= 3;
				}
				if (a % 2 != 0 && a % 3 != 0 && a > 2)
				{
					ez = false;
					cout << "NO";
					return 0;
				}
			}
			if (a == 1)
			{
				ez = true;
			}
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}
	if (ez)
	{
		cout << "YES";
	}
	else
		cout << "NO";
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[1000100];
long long int n, a, b;

int main()
{
	cin >> n;
	for (long long int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	bool ez = false;

	for (long long int i = 0; i < n; i++)
	{
		b = max(b, M[i]);
	}

	for (long long int i = 0; i < n; i++)
	{
		if (b % M[i] == 0)
		{
			a = b / M[i];
			while (a % 3 == 0)
			{
				a /= 3;
			}
			while (a % 2 == 0)
			{
				a /= 2;
			}
			if (a != 1)
			{
				cout << "NO";
				return 0;
			}
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}

	if (ez)
	{
		cout << "YES";
	}
	else
		cout << "NO";

}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[100010];
long long int n, a;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	sort(M, M + n);

	bool ez = true;

	for (int i = n-1; i > 0; i--)
	{
		if (M[n-1] % M[i] == 0)
		{
			a = M[n - 1] / M[i];
			while (a != 1)
			{
				if (a % 2 == 0)
				{
					a /= 2;
				}
				else if (a % 3 == 0)
				{
					a /= 2;
				}
				if(a % 2 != 0 && a % 3 != 0 && a > 2)
				{
					ez = false;
					cout << "NO";
					return 0;
				}
			}
			ez = true;
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}
	if (ez)
	{
		cout << "YES";
	}
	else
		cout << "NO";
}


#include <iostream>
#include <algorithm>
using namespace std;

long long int M[100010];
long long int n, a;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> M[i];
	}

	sort(M, M + n);

	bool ez = true;

	for (int i = n-1; i >= 0; i--)
	{
		if (M[n - 1] % M[i] == 0)
		{
			a = M[n - 1] / M[i];
			while (a != 1)
			{
				if (a % 2 == 0)
				{
					a /= 2;
				}
				else if (a % 3 == 0)
				{
					a /= 3;
				}
				if (a % 2 != 0 && a % 3 != 0 && a > 2)
				{
					ez = false;
					cout << "NO";
					return 0;
				}
			}
			if (a == 1)
			{
				ez = true;
			}
		}
		else
		{
			ez = false;
			cout << "NO";
			return 0;
		}
	}
	if (ez)
	{
		cout << "YES";
	}
	else
		cout << "NO";
}


//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr>
#define pr pair<int, int>
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

bool isPri(ll n){
	if(n<2){
		return true;
	}
	for(ll i=2;i*i<=n;i++){
		if(i%n==0) return false;
	}
	return true;
}

ll div(ll n){
	for(ll i=2;i*i<=n;i++){
		if(isPri(i)&&i%n&&i>3){
			return false;
		}
		if(n%i==0&&isPri(n/i)){
			return false;
		}
	}
	return true;
}

int solve()
{
	//happy coding

	ll n;
	cin>>n;
	ll a[n+1];
	ll x = 1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x = (x*a[i])/__gcd(x,a[i]);
	}

	for(int i=0;i<n;i++){
		ll y = x/a[i];
		//cout<<y<<endl;
		if(!div(y)){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}


//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr>
#define pr pair<int, int>
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

bool isPri(ll n){
	if(n<2){
		return true;
	}
	for(ll i=2;i*i<=n;i++){
		if(i%n==0) return false;
	}
	return true;
}

ll div(ll n){
	for(ll i=2;i*i<=n;i++){
		if(isPri(i)&&n%i==0&&i>3){
			return false;
		}if(n%i==0){
			ll x = n/i;
			if(isPri(x)&&x>3) return false;
		}
	}

	return true;
}

int solve()
{
	//happy coding

	ll n;
	cin>>n;
	ll a[n+1];
	ll x = 1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x = (x*a[i])/__gcd(x,a[i]);
	}

	for(int i=0;i<n;i++){
		ll y = x/a[i];
		//cout<<y<<endl;
		if(!div(y)){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

ll t[1005*1005];

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	ll x = 0;
	for(int i=1;i<=n;i++){
		cin>>t[i];
		x = __gcd(x,t[i]);
	}

	while(x%2==0)x/=2;
	while(x%3==0)x/=3;

	for(int i=1;i<=n;i++){
		ll two =1,three = 1;
		while(t[i] % (two*2)== 0) two *= 2;
		while(t[i] % (three*3)==0) three *= 3;
		if(x*three*two!= t[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr>
#define pr pair<int, int>
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

bool isPri(ll n){
	if(n<2){
		return true;
	}
	for(ll i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return true;
}

ll div(ll n){
	for(ll i=2;i*i<=n;i++){
		if(isPri(i)&&i%n&&i>3){
			return false;
		}
		if(n%i==0&&isPri(n/i)){
			return false;
		}
	}
	return true;
}

int solve()
{
	//happy coding
	ll n;
	cin>>n;
	ll a[n+1];
	ll x = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x = __gcd(x,a[i]);
	}

	for(int i=0;i<n;i++){
		ll y = a[i]/x;
		if(y>3&&isPri(y)){
			//cout<<y<<endl;
			cout<<"No"<<endl;
			return 0;
		}
	}
	//cout<<x<<endl;
	cout<<"Yes"<<endl;

	return 0;
}

int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}


#include <bits/stdc++.h>
using namespace std;

int t[1005*1005];

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>t[i];
		while(t[i] % 2 == 0) t[i]/=2;
		while(t[i] % 3 == 0) t[i]/=3;
	}
	for(int i=1;i<=n;i++){
		if(t[i] != t[1]){
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");
	return 0;
}


/*
**   Contest : Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1)
**   Problem : A. Bear and Poker
**
**    Author : Dhiraj Govindvira
**      Date : 14-Apr-2020 ~ Tuesday
**      Time : 06:25:42 PM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
#endif

// Data Type ----------------------------------------------------------------

#define fast                ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Stl ----------------------------------------------------------------------

#define vll                 vector<ll>
#define vvl                 vector<vll>
#define pll                 pair<ll,ll>
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

template <typename T>
inline bool inrange(T a, T l, T r) {
    if(l>r) swap(l,r);
    return (a>=l and a<=r);
}
template <typename T, typename U>
inline bool exist(T val, U &any) {
    return (any.find(val) != any.end());
}
// multiple input
template <typename T>
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U>
inline void inp(T &a,U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T>
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second;
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n;
    std::cin>>n;

    vector<ll> a(n);
    std::cin>>a;

    map<ll,ll> m;
    loop(i,0,n)
    {
        ll x = a[i];
        ll sqr = sqrt(x);
        loop(j,2,sqr+1)
        {
            ll cnt = 0;
            while(x%j==0)
            {
                cnt++;
                x /= j;
            }
            if(cnt and j>3)
            {
                if(!i and !m[j]) m[j] = cnt;
                else if(m[j]!=cnt)
                {
                    cout<<"No\n";
                    return;
                }
            }
            d(j,x,m);
        }
        if(x>3)
        {
            if(!i and !m[x]) m[x] = 1;
            else if(m[x]!=1)
            {
                cout<<"No\n";
                return;
            }
        }
    }
    cout<<"Yes\n";
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    fast;
    int t = 1;
    loop(i,1,t+1)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}


/*
**   Contest : Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1)
**   Problem : A. Bear and Poker
**
**    Author : Dhiraj Govindvira
**      Date : 14-Apr-2020 ~ Tuesday
**      Time : 06:25:42 PM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
#endif

// Data Type ----------------------------------------------------------------

#define fast                ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Stl ----------------------------------------------------------------------

#define vll                 vector<ll>
#define vvl                 vector<vll>
#define pll                 pair<ll,ll>
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

template <typename T>
inline bool inrange(T a, T l, T r) {
    if(l>r) swap(l,r);
    return (a>=l and a<=r);
}
template <typename T, typename U>
inline bool exist(T val, U &any) {
    return (any.find(val) != any.end());
}
// multiple input
template <typename T>
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U>
inline void inp(T &a,U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T>
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second;
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n;
    std::cin>>n;

    vector<ll> a(n);
    std::cin>>a;

    map<ll,ll> m;
    loop(i,0,n)
    {
        ll x = a[i];
        ll sqr = sqrt(x);
        loop(j,2,sqr+1)
        {
            ll cnt = 0;
            while(x%j==0)
            {
                cnt++;
                x /= j;
            }
            if(cnt and j>3)
            {
                if(!m[j]) m[j] = cnt;
                else if(m[j]!=cnt)
                {
                    cout<<"No\n";
                    return;
                }
            }
        }
        if(x>3)
        {
            if(!m[x]) m[x] = 1;
            else if(m[x]!=1)
            {
                cout<<"No\n";
                return;
            }
        }
    }
    cout<<"Yes\n";
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    fast;
    int t = 1;
    loop(i,1,t+1)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}


/*
**   Contest : Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1)
**   Problem : A. Bear and Poker
**
**    Author : Dhiraj Govindvira
**      Date : 14-Apr-2020 ~ Tuesday
**      Time : 06:25:42 PM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
#endif

// Data Type ----------------------------------------------------------------

#define fast                ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Stl ----------------------------------------------------------------------

#define vll                 vector<ll>
#define vvl                 vector<vll>
#define pll                 pair<ll,ll>
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

template <typename T>
inline bool inrange(T a, T l, T r) {
    if(l>r) swap(l,r);
    return (a>=l and a<=r);
}
template <typename T, typename U>
inline bool exist(T val, U &any) {
    return (any.find(val) != any.end());
}
// multiple input
template <typename T>
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U>
inline void inp(T &a,U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T>
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second;
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n;
    std::cin>>n;

    vector<ll> a(n);
    std::cin>>a;

    ll x = a[0];
    while(x%2==0) x /= 2;
    while(x%3==0) x /= 3;

    loop(i,1,n)
    {
        ll y = a[i];
        while(y%2==0) y /= 2;
        while(y%3==0) y /= 3;
        if(x!=y)
        {
            cout<<"No\n";
            return;
        }
    }
    cout<<"Yes\n";
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    fast;
    int t = 1;
    loop(i,1,t+1)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}


/*
**   Contest : Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1)
**   Problem : A. Bear and Poker
**
**    Author : Dhiraj Govindvira
**      Date : 14-Apr-2020 ~ Tuesday
**      Time : 06:25:42 PM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
#endif

// Data Type ----------------------------------------------------------------

#define fast                ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Stl ----------------------------------------------------------------------

#define vll                 vector<ll>
#define vvl                 vector<vll>
#define pll                 pair<ll,ll>
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

template <typename T>
inline bool inrange(T a, T l, T r) {
    if(l>r) swap(l,r);
    return (a>=l and a<=r);
}
template <typename T, typename U>
inline bool exist(T val, U &any) {
    return (any.find(val) != any.end());
}
// multiple input
template <typename T>
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U>
inline void inp(T &a,U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T>
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second;
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n;
    std::cin>>n;

    vector<ll> a(n);
    std::cin>>a;

    map<ll,ll> m;
    loop(i,0,n)
    {
        ll x = a[i];
        ll sqr = sqrt(x);
        loop(j,2,sqr+1)
        {
            ll cnt = 0;
            while(x%j==0)
            {
                cnt++;
                x /= j;
            }
            if(cnt and j>3)
            {
                if(!i and !m[j]) m[j] = cnt;
                else if(m[j]!=cnt)
                {
                    cout<<"No\n";
                    return;
                }
            }
            d(j,x,m);
        }
        if(x>3)
        {
            if(!i and !m[x]) m[x] = 1;
            else if(m[x]!=1)
            {
                cout<<"No\n";
                return;
            }
        }
    }
    cout<<"Yes\n";
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    fast;
    int t = 2;
    loop(i,1,t+1)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}


/*
**   Contest : Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1)
**   Problem : A. Bear and Poker
**
**    Author : Dhiraj Govindvira
**      Date : 14-Apr-2020 ~ Tuesday
**      Time : 06:25:42 PM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
#endif

// Data Type ----------------------------------------------------------------

#define fast                ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Stl ----------------------------------------------------------------------

#define vll                 vector<ll>
#define vvl                 vector<vll>
#define pll                 pair<ll,ll>
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

template <typename T>
inline bool inrange(T a, T l, T r) {
    if(l>r) swap(l,r);
    return (a>=l and a<=r);
}
template <typename T, typename U>
inline bool exist(T val, U &any) {
    return (any.find(val) != any.end());
}
// multiple input
template <typename T>
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U>
inline void inp(T &a,U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T>
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second;
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n;
    std::cin>>n;

    vector<ll> a(n);
    std::cin>>a;

    map<ll,ll> m;
    map<ll,bool> vis;
    loop(i,0,n)
    {
        ll x = a[i];
        if(vis[x]) continue;

        vis[x] = true;
        ll sqr = sqrt(x);
        loop(j,2,sqr+1)
        {
            ll cnt = 0;
            while(x%j==0)
            {
                cnt++;
                x /= j;
            }
            if(cnt and j>3)
            {
                if(!i) m[j] = cnt;
                else if(m[j]!=cnt)
                {
                    cout<<"No\n";
                    return;
                }
            }
        }
        if(x>3)
        {
            if(!i) m[x] = 1;
            else if(m[x]!=1)
            {
                cout<<"No\n";
                return;
            }
        }
    }
    cout<<"Yes\n";
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    fast;
    int t = 1;
    loop(i,1,t+1)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}


/*
**   Contest : Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1)
**   Problem : A. Bear and Poker
**
**    Author : Dhiraj Govindvira
**      Date : 14-Apr-2020 ~ Tuesday
**      Time : 06:25:42 PM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
#endif

// Data Type ----------------------------------------------------------------

#define fast                ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Stl ----------------------------------------------------------------------

#define vll                 vector<ll>
#define vvl                 vector<vll>
#define pll                 pair<ll,ll>
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

template <typename T>
inline bool inrange(T a, T l, T r) {
    if(l>r) swap(l,r);
    return (a>=l and a<=r);
}
template <typename T, typename U>
inline bool exist(T val, U &any) {
    return (any.find(val) != any.end());
}
// multiple input
template <typename T>
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U>
inline void inp(T &a,U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T>
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second;
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n;
    std::cin>>n;

    vector<ll> a(n);
    std::cin>>a;

    map<ll,ll> m;
    map<ll,ll> vis;
    loop(i,0,n)
    {
        ll x = a[i];
        if(vis[x]) continue;

        vis[x] = true;
        ll sqr = sqrt(x);
        loop(j,2,sqr+1)
        {
            ll cnt = 0;
            while(x%j==0)
            {
                cnt++;
                x /= j;
            }
            if(cnt and j>3)
            {
                if(!i and !m[j]) m[j] = cnt;
                else if(m[j]!=cnt)
                {
                    cout<<"No\n";
                    return;
                }
            }
        }
        if(x>3)
        {
            if(!i and !m[x]) m[x] = 1;
            else if(m[x]!=1)
            {
                cout<<"No\n";
                return;
            }
        }
    }
    cout<<"Yes\n";
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    fast;
    int t = 1;
    loop(i,1,t+1)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std ;
long long a[10000001] ;
int main(){
    int n ; cin >> n ;
    for(int i = 0 ; i < n; i ++ ) {
        cin >> a[i] ;
    }
    sort(a,a+n);
    bool check = true ;
    long long temp = a[n-1] ;
    for(int i = 0 ; i < n-1 ; i ++ ) {
        if(!((temp/a[i]) == 2.0 || (temp/a[i]) == 3.0)){
            check = false ;
            break;
        }
    }
    if(check) cout << "Yes"<< endl;
    else cout <<"No"<< endl;
}


#include<bits/stdc++.h>
using namespace std ;
long long a[10000001] ;
int main(){
    int n ; cin >> n ;
    for(int i = 0 ; i < n; i ++ ) {
        cin >> a[i] ;
    }
    sort(a,a+n);
    bool check = true ;
    int dem2=  0;
    int dem3 = 0 ;
    long long temp = a[n-1] ;
    for(int i = 0 ; i < n-1 ; i ++ ) {
        if(temp % a[i] == 0){
            double k = 1.0*temp/a[i] ;
            if(k == 2){
                dem2++;
            }
            if(k == 3){
                dem3++;
            }
        }
    }
    if(dem2 != 0 || dem3 != 0) cout <<"Yes"<< endl;
    else cout <<"No"<< endl;
}


#include<bits/stdc++.h>
using namespace std ;
long long a[10000001] ;
int main(){
    int n ; cin >> n ;
    for(int i = 0 ; i < n; i ++ ) {
        cin >> a[i] ;
    }
    sort(a,a+n);
    bool check = true ;
    int dem2=  0;
    int dem3 = 0 ;
    long long temp = a[n-1] ;
    for(int i = 0 ; i < n-1 ; i ++ ) {
        if(temp % a[i] == 0){
            double k = 1.0*temp/a[i] ;
            if(k == 2){
                dem2++;
            }
            if(k == 3){
                dem3++;
            }
        }
    }
    if(dem2 != 0 && dem3 != 0) cout <<"Yes"<< endl;
    else cout <<"No"<< endl;
}


#include<bits/stdc++.h>
using namespace std ;
long long a[10000001] ;
int main(){
    int n ; cin >> n ;
    for(int i = 0 ; i < n; i ++ ) {
        cin >> a[i] ;
    }
    sort(a,a+n);
    bool check = true ;
    int dem2=  0;
    int dem3 = 0 ;
    long long temp = a[n-1] ;
    for(int i = 0 ; i < n-1 ; i ++ ) {
        if(temp % a[i] == 0){
            double k = 1.0*temp/a[i] ;
            if(k == 2){
                dem2++;
            }
           else  if(k == 3){
                dem3++;
            }
            else {
                check = false ;
                break ;
            }
        }
    }
    if(check == false ) cout <<"No"<< endl;
    else if(dem2+dem3 == n - 1 ) cout <<"Yes"<< endl;
    else cout <<"No"<< endl;
}


#include<bits/stdc++.h>
using namespace std ;
long long a[10000001] ;
int main(){
    int n ; cin >> n ;
    for(int i = 0 ; i < n; i ++ ) {
        cin >> a[i] ;
    }
    sort(a,a+n);
    bool check = true ;
    int dem2=  0;
    int dem3 = 0 ;
    long long temp = a[n-1] ;
    for(int i = 0 ; i < n-1 ; i ++ ) {
        if(temp % a[i] == 0){
            double k = 1.0*temp/a[i] ;
            if(k == 2){
                dem2++;
            }
           else  if(k == 3){
                dem3++;
            }
            else {
                check = false ;
                break ;
            }
        }else {
            check =false ;
            break;
        }
    }
    if(check == false ) cout <<"No"<< endl;
    else {
       cout <<"Yes"<< endl;

    }
}


#include<bits/stdc++.h>
using namespace std ;
long long a[10000001] ;
int main(){
    int n ; cin >> n ;
    for(int i = 0 ; i < n; i ++ ) {
        cin >> a[i] ;
    }
    sort(a,a+n);
    bool check = true ;
    int dem2=  0;
    int dem3 = 0 ;
    long long temp = a[n-1] ;
    for(int i = 0 ; i < n-1 ; i ++ ) {
        if(temp % a[i] == 0 && temp != a[i]){
                double k = temp/a[i];
                if(k != 2.0 && k!= 3.0)
                {
                    cout <<"No"<< endl;
                    return 0;
                }
        }
    }
    cout <<"Yes"<< endl;
}


#include<bits/stdc++.h>
using namespace std ;
long long a[10000001] ;
long double k[10000001] ;
int main(){
    int n ; cin >> n ;
    for(int i = 0 ; i < n; i ++ ) {
        cin >> a[i] ;
    }
    sort(a,a+n);
    bool check = true ;
    int dem2=  0;
    int dem3 = 0 ;
    set<double> p ;
    long long temp = a[n-1] ;
    for(int i = 0 ; i < n-1 ; i ++ ) {
        if(temp % a[i] == 0 && temp != a[i]){
             double k = temp/a[i];
            p.insert(k) ;
        }
    }
    for(set<double>::iterator it = p.begin() ; it != p.end() ; it++ ){
        if(*it == 2)
        {
            continue ;
        }
        if(*it == 3){
            continue ;
        }else {
            cout <<"No"<< endl;
            return 0 ;
        }
    }
    cout <<"Yes"<< endl;
}


#include<bits/stdc++.h>
using namespace std ;
long long a[10000001] ;
long double k[10000001] ;
int main(){
    int n ; cin >> n ;
    for(int i = 0 ; i < n; i ++ ) {
        cin >> a[i] ;
    }
    sort(a,a+n);
    bool check = true ;
    int dem2=  0;
    int dem3 = 0 ;
    set<double> p ;
    long long temp = a[n-1] ;
    for(int i = 0 ; i < n-1 ; i ++ ) {
        if(temp % a[i] == 0 && temp != a[i]){
             double k = temp/a[i];
            p.insert(k) ;
        }
    }
    if(p.size() > 2) cout <<"No"<< endl;
    else cout <<"Yes"<< endl;
}


#include<bits/stdc++.h>
using namespace std ;
long long a[10000001] ;
int main(){
    int n ; cin >> n ;
    for(int i = 0 ; i < n; i ++ ) {
        cin >> a[i] ;
    }
    sort(a,a+n);
    bool check = true ;
    int dem2=  0;
    int dem3 = 0 ;
    long long temp = a[n-1] ;
    for(int i = 0 ; i < n-1 ; i ++ ) {
        if(temp % a[i] == 0){
            double k = 1.0*temp/a[i] ;
            if(k == 2){
                dem2++;
            }
           else  if(k == 3){
                dem3++;
            }
            else {
                check = false ;
                break ;
            }
        }
    }
    if(check == false ) cout <<"No"<< endl;
    else cout <<"Yes"<< endl;
}


/*oyce*/
#include<iostream>
using namespace std;
const int N = 100001;
int a[N];
int main()
{
	int i, n, j,counter=1,flag=1;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> a[i];
	for (i = 0; i < n ; i++)
	{

		if (a[i] < a[i + 1])
			flag++;
        else flag = 1;
        if (flag > counter)
        {
            counter = flag;

        }
	}

	cout << counter <<endl;
	return 0;
}


/*290z*/

#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
using namespace std;
typedef __int64 LL;

const int N=1e5+10;

int n;
int a[N];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    int s,t,ans,temp;
    s=t=1;
    ans=1;
    temp=0;
    while(s<=n)
    {
        while(t+1<=n&&a[t]<a[t+1])
        {
            temp=t-s+2;
            t++;
        }
        s=t+1;
        t=t+1;
        ans=max(temp,ans);
    }
    printf("%d\n",ans);
    return 0;
}


/*uxwa*/
#include<iostream>
using namespace std;
void main(){
 int n;
 cin>>n;
 int *a,*b;
 a=new int [n];
 b=new int [n];
 for(int i=0;i<n;i++){
  cin>>a[i];
  b[i]=1;
 }
 for(int i=0;i<n;i++){
   int i1=i;
   while(a[i1]>a[i1-1]&&i-1>=0)
	 {  b[i]++; i1--;
   }
 }
 int max=1;
 for(int i=0;i<n;i++){
  if(max<b[i])max=b[i];
 }
 cout<<max;
 system("pause");
}


/*ku77*/
#include <stdio.h>
int main ()
{
    int a,b,c,d=1,max=1,n;
    scanf("%d",&n);
    scanf("%d",&b);
    for (a=1;a<n;a++)
    {
        scanf("%d",&c);
        if (c>b)d++;
        else {if(max<d)max=d;d=1;}
        b=c;
    }
    if(max<d)max=d;
    printf("%d\n",max);
    return 0;
}


/*hm9k*/
#include<iostream>
using namespace std;
const int N = 100001;
int a[N];
int main()
{
	int i, n, j, flag = 0,counter = 0;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> a[i];
	for (i = 0; i < n - 1; i++)
	{
		if (flag < counter)
			flag = counter;
		counter = 1;
		for (j = i; j < n - 1; j++)
		{
			if (a[j] < a[j + 1])
				counter++;
			else
			{
				break;
			}

		}

	}
	cout << flag << endl;
	return 0;
}


/*skng*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *p,l,i,a=1,b=1,temp;
    while(scanf("%d",&l))
    {
        p=calloc(l,sizeof(int));
        for(i=0;i<l;i++)
            scanf("%d",&p[i]);
        for(i=0;i<l-1;i++)
        {
            if(p[i]<p[i+1])
            {
                if((a==1&&b==1)||temp==1)
                {
                    a++;
                    temp=1;
                }
                else if(a!=1||temp==2)
                {
                    b++;
                    temp=2;
                }
                else if(b!=1||temp==3)
                {
                    a++;
                    temp=3;
                }
            }
            else
            {
                if(a>b)
                {
                    b=1;
                    temp=0;
                }
                else
                {
                    a=1;
                    temp=0;
                }
            }
        }
        free(p);
        if(a>b) printf("%d",a);
        else printf("%d",b);
    }
    return 0;
}


/*ythj*/
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int n,a,b,res=1,result=1;
    scanf("%d",&n);
    scanf("%d",&a);
    for(int i=1;i<n;i++){
        scanf("%d",&b);
        if(b>a){
            res++;
        }else{
            res=1;
        }
        a=b;
        if(res>result)
            result=res;
    }
    printf("%d\n",result);
}


/*vjie*/
#include <stdio.h>

int main()
{
    int n;
    int index;
    int max = 0;
    int a[100001];
    scanf("%d", &n);
    for (int i = 0; i < n; i ++)
        scanf("%d", &a[i]);
    for (int i = 0; i < n; i ++)
    {
        int index = i;
        while ((a[index] < a[index + 1]) && (index + 1 < n))
            index ++;
        if (index - i + 1 > max)
            max = index - i + 1;
        i = index;
    }
    printf("%d\n", max);
    return 0;
}


/*dmsg*/

#include <cstdio>
#define MAX 100005
#include <cstring>
#include<algorithm>
using namespace std;
int shu[MAX];
int comp[MAX];
int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        memset(shu,0,sizeof(shu));
        memset(comp,0,sizeof(comp));
        for(int i=1;i<=n;i++)
            scanf("%d",&shu[i]);
        comp[1]=1;
        int maxx=0;
        for(int i=2;i<=n;i++)
        {
            if(shu[i-1]<shu[i])
            {
                comp[i]=comp[i-1]+1;
            }
            else
            {
                comp[i]=1;
            }
        }
        for(int i=1;i<=n;i++)
       maxx=max(maxx,comp[i]);
       printf("%d\n",maxx);
    }
    return 0;
}


/*lspd*/
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int i,a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int count,ans;
	count=1;
	ans=count;
	for(i=1;i<n;i++){
		if(a[i]>a[i-1]){
			count++;
		}
		else{
			if(ans<count){
				ans=count;
			}
			count=1;
		}
	}
	if(ans<count){
		ans=count;
	}
	printf("%d\n",ans);
	return 0;
}


/*juue*/
#include <stdio.h>
#include <stdlib.h>

long a[100000];
int b[100000] = {0};

int main()
{
    int i, n;
    int m, iCount=1, iResult=1;
    scanf("%d", &n);
    for (i=0; i<n; i++)
    {
        scanf("%ld", &a[i]);
    }
    j = 0;
    m = a[0];
        for (i=1; i<n; i++)
    {
        if (a[i] > m)
            iCount++;
        else
            iCount = 1;
        m = a[i];
        if (iCount>iResult)
            iResult = iCount;
    }
    printf("%d\n", iResult);
    return 0;
}


/*sqbh*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *p,l,i,a=1,b=1,temp;
    scanf("%d",&l);
    p=(int*)calloc(l,sizeof(int));
    for(i=0;i<l;i++)
        scanf("%d",&p[i]);
    for(i=0;i<l-1;i++)
    {
        if(p[i]<p[i+1])
        {
            if((a==1&&b==1)||temp==1)
            {
                a++;
                temp=1;
            }
            else if(a!=1||temp==2)
            {
                b++;
                temp=2;
            }
            else if(b!=1||temp==3)
            {
                a++;
                temp=3;
            }
        }
        else
        {
            if(a>b)
            {
                b=1;
                temp=0;
            }
            else
            {
                a=1;
                temp=0;
            }
        }
    }
    free(p);
    if(a>b) printf("%d",a);
    else printf("%d",b);
    return 0;
}


/*106x*/
#include <stdio.h>

int main()
{
    int n;
    int index;
    int max = 0;
    int a[100001];
    scanf("%d", &n);
    for (int i = 0; i < n; i ++)
        scanf("%d", &a[i]);
    for (int i = 0; i < n; i ++)
    {
        int index = i;
        while ((a[index] < a[index + 1]) && (index + 1 < n))
            index ++;
        if (index - i + 1 > max)
            max = index - i + 1;
        i = index;
    }
    printf("%d\n", max);
    return 0;
}


/*cqby*/
#include <iostream>
#include <algorithm>
using namespace std;

int b[10000],a[1000];

bool compare(int a,int b)
{
      return a>b;
}

int main()
{
	int n,k=1,l=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(i<n&&b[i]>b[i-1])
			{
				k++;
				continue;
			}
		else
		{
			a[l++]=k;
			k=1;
		}
	}
	sort(a,a+l,compare);
	cout<<a[0]<<endl;
	return 0;
}


/*hod0*/
#include<stdio.h>
#include<algorithm>
using namespace std;

struct card
{
    int id;
    int value;
};

card a[100];
bool cmp(card a,card b)
{
    return a.value<b.value;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        a[i].id=i+1;
        scanf("%d",&(a[i].value));
    }
    sort(a,a+n,cmp);
    for(int i=0;i<n/2;i++)
    {
        printf("%d %d\n",a[i].id,a[n-1-i].id);
    }
    return 0;
}