#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int lcm(int a,int b){return ((a*b)/gcd(a,b));}

long long a[100000];
int main()
{
    long long i,j,k,l,m,n;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if((lcm(a[i],a[j])/a[i]>3)||(lcm(a[i],a[j])/a[j])>3)
            {
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}


#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>

using namespace std;

long long gcd(long long a,long long b){return b==0?a:gcd(b,a%b);}
long long lcm(long a,long b){return ((a*b)/gcd(a,b));}

long long a[100000];
int main()
{
    long long i,j,k,l,m,n,maxx=0,g=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);

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


#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

long long gcd(long long a,long long b){return b==0?a:gcd(b,a%b);}
long long lcm(long a,long b){return ((a*b)/gcd(a,b));}

long long a[100000];
int main()
{
    long long i,j,k,l,m,n,maxx=0,g=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
        if(i==1)
        {
            maxx=lcm(a[i],a[0]);
        }
        if(i>1)
        {
            maxx=lcm(maxx,a[i]);
        }

    }

    for(i=0;i<n;i++)
    {
        j=a[i];
        while(a[i]<maxx)
        {
            a[i]*=2;
            if(a[i]==maxx)
                g=1;
        }
        a[i]=j;
        if((g==1)||(a[i]==maxx))
           {
               g=0;
               continue;
           }
        else
        {
                while(a[i]<maxx)
                {
                    a[i]*=3;
                    if(a[i]==maxx)
                        g=1;
                }
            if(g==1)
            {
                g=0;
                continue;
            }
            else
            {
                cout << "NO" << endl;
                return 0;
            }

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


#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

long long gcd(int a,int b){return b==0?a:gcd(b,a%b);}
long long lcm(int a,int b){return ((a*b)/gcd(a,b));}

long long a[100000];
int main()
{
    long long i,j,k,l,m,n;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(a[i]<a[j])
            {
                if((gcd((lcm(a[i],a[j])/a[i]),2)==1)&&(gcd((lcm(a[i],a[j])/a[i]),3)==1)&&(a[i]!=a[j]))
                {
                    cout << "NO" << endl;
                    return 0;
                }
            }
            else
            {
                if((gcd((lcm(a[i],a[j])/a[j]),2)==1)&&(gcd((lcm(a[i],a[j])/a[j]),3)==1)&&(a[i]!=a[j]))
                {
                    cout << "NO" << endl;
                    return 0;
                }

            }
        }

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


#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>

using namespace std;

long long gcd(long long a,long long b){return b==0?a:gcd(b,a%b);}
long long lcm(long a,long b){return ((a*b)/gcd(a,b));}

long long a[100000];
int main()
{
    long long i,j,k,l,m,n,maxx=0,g=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);

    for(i=0;i<n;i++)
    {
        while(a[i]%2==0)
        {
            a[i]/=2;
        }
        while(a[i]%3==0)
        {
            a[i]/=3;
        }
    }
    sort(a,a+n);
    if(a[0]==a[n-1])
        cout << "Yes" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


#include<iostream>
//#include<conio.h>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
    int temp;
    while (b != 0)
    {
        temp = a % b;
        a = b;
        b = temp;
    }
    return a;
}
long long lcm(long long a,long long b)
{
    return ((long long)a*b)/gcd(a, b);
}
bool powerofa(int n, int a)
{
     while (n % a == 0) {
     n /= a;
     }
     return n == 1;
}
int main()
{
    //while(1){
    int N;
    cin>>N;
    vector<int> bids;
    int i=0;
    while(i<N)
    {
              int a;
              cin>>a;
              bids.push_back(a);
              i++;
    }
    int reslcm =1;
    for(int i=0;i<N;i++)
    {
            reslcm = lcm(reslcm,bids[i]);
    }
    //cout<<"Got: "<<reslcm<<endl;
    bool flag=true;
    for(int i=0;i<N;i++)
    {
            int tmp = reslcm/bids[i];
            //cout<<"Temp:"<<tmp<<endl;
            if(tmp==1 || powerofa(tmp,2) || powerofa(tmp,3) || powerofa(tmp,6))
            {
                      //cout<<"gyaa\n";
                      continue;
            }
            else
            {
                flag = false;
                break;
            }
    }
    if(flag)
       cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    //}
  //  getch();
    return 0;
}


#include<iostream>
//#include<conio.h>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
    int temp;
    while (b != 0)
    {
        temp = a % b;
        a = b;
        b = temp;
    }
    return a;
}
long long lcm(long long a,long long b)
{
    return ((long long)a*b)/gcd(a, b);
}
bool powerofa(int n, int a)
{
     while (n % a == 0) {
     n /= a;
     }
     return n == 1;
}
int main()
{
    //while(1){
    int N;
    cin>>N;
    vector<int> bids;
    int i=0;
    while(i<N)
    {
              int a;
              cin>>a;
              bids.push_back(a);
              i++;
    }
    int reslcm =1;
    for(int i=0;i<N;i++)
    {
            reslcm = lcm(reslcm,bids[i]);
    }
    //cout<<"Got: "<<reslcm<<endl;
    bool flag=true;
    for(int i=0;i<N;i++)
    {
            int tmp = reslcm/bids[i];
            while(tmp%2==0)tmp /=2;
            while(tmp%3==0)tmp /=3;
            if(tmp==1)
                      continue;
            else
            {
                flag = false;
                break;
            }
    }
    if(flag)
       cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    //}
  //  getch();
    return 0;
}


#include<iostream>
//#include<conio.h>
#include<vector>
using namespace std;
int main()
{
    //while(1){
    int N,M;
    cin>>N>>M;
    vector<vector<int> > v(N+1,vector<int>(N+1,0));
    vector<int> deg(N+1,0);
    vector<pair<int,int> > p;
    int i=0;
    while(i<M)
    {
              int a,b;
              cin>>a>>b;
              p.push_back(make_pair(a,b));
              deg[a]++;
              deg[b]++;
              v[a][b] =1;
              v[b][a] =1;
              i++;
    }
    int mini = INT_MAX;
    for(vector<pair<int,int> >::iterator it=p.begin();it!=p.end();it++)
    {
                             for(int i=1;i<=N;i++)
                             {
                                     if(v[it->first][i] && v[it->second][i])
                                     {
                                           int x = deg[i] + deg[it->first] +deg[it->second] -6;
                                           if(x < mini)
                                           {
                                                mini = x;
                                           }
                                     }
                             }
    }
    if(mini==INT_MAX)
        cout<<-1<<endl;
    else
        cout<<mini<<endl;
    //}
  //  getch();
    return 0;
}


#include<iostream>
//#include<conio.h>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
    int temp;
    while (b != 0)
    {
        temp = a % b;
        a = b;
        b = temp;
    }
    return a;
}
long long lcm(long long a,long long b)
{
    return ((long long)a*b)/gcd(a, b);
}
int main()
{
    //while(1){
    int N;
    cin>>N;
    vector<int> bids;
    int i=0;
    while(i<N)
    {
              int a;
              cin>>a;
              bids.push_back(a);
              i++;
    }
    int reslcm =1;
    for(int i=0;i<N;i++)
    {
            reslcm = lcm(reslcm,bids[i]);
    }
    cout<<"Got: "<<reslcm<<endl;
    bool flag=true;
    for(int i=0;i<N;i++)
    {
            int tmp = reslcm/bids[i];
            if(tmp==1 || !tmp%2 || !tmp%3 || !tmp%6)
                      continue;
            else
                flag = false;
    }
    if(flag)
       cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    //}
  //  getch();
    return 0;
}


#include<iostream>
//#include<conio.h>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
    int temp;
    while (b != 0)
    {
        temp = a % b;
        a = b;
        b = temp;
    }
    return a;
}
long long lcm(long long a,long long b)
{
    return ((long long)a*b)/gcd(a, b);
}
bool powerofa(int n, int a)
{
     while (n % a == 0) {
     n /= a;
     }
     return n == 1;
}
int main()
{
    //while(1){
    int N;
    cin>>N;
    vector<int> bids;
    int i=0;
    while(i<N)
    {
              int a;
              cin>>a;
              bids.push_back(a);
              i++;
    }
    bool flag=true;
    for(int i=0;i<N;i++)
    {
            while(bids[i]%2==0)bids[i] /=2;
            while(bids[i]%3==0)bids[i] /=3;
    }
    for(int i=1;i<N;i++)
    {
            if(bids[i]!=bids[i-1])
                                  break;
    }
    if(i<N)
       cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    //}
  //  getch();
    return 0;
}


#include<iostream>
//#include<conio.h>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
    int temp;
    while (b != 0)
    {
        temp = a % b;
        a = b;
        b = temp;
    }
    return a;
}
long long lcm(long long a,long long b)
{
    return ((long long)a*b)/gcd(a, b);
}
bool powerofa(int n, int a)
{
     while (n % a == 0) {
     n /= a;
     }
     return n == 1;
}
int main()
{
    //while(1){
    int N;
    cin>>N;
    vector<int> bids;
    int i=0;
    while(i<N)
    {
              int a;
              cin>>a;
              bids.push_back(a);
              i++;
    }
    bool flag=true;
    for(int i=0;i<N;i++)
    {
            int tmp = reslcm/bids[i];
            while(tmp%2==0)tmp /=2;
            while(tmp%3==0)tmp /=3;
            if(tmp==1)
                      continue;
            else
            {
                flag = false;
                break;
            }
    }
    for(int i=1;i<N;i++)
    {
            if(bids[i]!=bids[i-1])
                                  break;
    }
    if(i<N)
       cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    //}
  //  getch();
    return 0;
}


#include<iostream>
//#include<conio.h>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
    int temp;
    while (b != 0)
    {
        temp = a % b;
        a = b;
        b = temp;
    }
    return a;
}
long long lcm(long long a,long long b)
{
    return ((long long)a*b)/gcd(a, b);
}
bool powerofa(int n, int a)
{
     while (n % a == 0) {
     n /= a;
     }
     return n == 1;
}
int main()
{
    while(1){
    int N;
    cin>>N;
    vector<int> bids;
    int i=0;
    while(i<N)
    {
              int a;
              cin>>a;
              bids.push_back(a);
              i++;
    }
    bool flag=true;
    for(i=0;i<N;i++)
    {
            while(bids[i]%2==0)bids[i] /=2;
            while(bids[i]%3==0)bids[i] /=3;
    }
    for(i=1;i<N;i++)
    {
            if(bids[i]!=bids[i-1])
                                  break;
    }
    if(i<N)
       cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    }
  //  getch();
    return 0;
}


#include<iostream>
//#include<conio.h>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
    int temp;
    while (b != 0)
    {
        temp = a % b;
        a = b;
        b = temp;
    }
    return a;
}
long long lcm(long long a,long long b)
{
    return ((long long)a*b)/gcd(a, b);
}
bool powerofa(int n, int a)
{
     while (n % a == 0) {
     n /= a;
     }
     return n == 1;
}
int main()
{
    //while(1){
    int N;
    cin>>N;
    vector<int> bids;
    int i=0;
    while(i<N)
    {
              int a;
              cin>>a;
              bids.push_back(a);
              i++;
    }
    bool flag=true;
    for(i=0;i<N;i++)
    {
            while(bids[i]%2==0)bids[i] /=2;
            while(bids[i]%3==0)bids[i] /=3;
    }
    for(i=1;i<N;i++)
    {
            if(bids[i]!=bids[i-1])
                                  break;
    }
    if(i<N)
       cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    //}
  //  getch();
    return 0;
}


#include<iostream>
//#include<conio.h>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
    int temp;
    while (b != 0)
    {
        temp = a % b;
        a = b;
        b = temp;
    }
    return a;
}
long long lcm(long long a,long long b)
{
    return ((long long)a*b)/gcd(a, b);
}
int main()
{
    //while(1){
    int N;
    cin>>N;
    vector<int> bids;
    int i=0;
    while(i<N)
    {
              int a;
              cin>>a;
              bids.push_back(a);
              i++;
    }
    int reslcm =1;
    for(int i=0;i<N;i++)
    {
            reslcm = lcm(reslcm,bids[i]);
    }
    bool flag=true;
    for(int i=0;i<N;i++)
    {
            int tmp = reslcm/bids[i];
            if(!tmp%2 || !tmp%3 || !tmp%6)
                      continue;
            else
                flag = false;
    }
    if(flag)
       cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    //}
  //  getch();
    return 0;
}


#include<iostream>
//#include<conio.h>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
    int temp;
    while (b != 0)
    {
        temp = a % b;
        a = b;
        b = temp;
    }
    return a;
}
long long lcm(long long a,long long b)
{
    return ((long long)a*b)/gcd(a, b);
}
int main()
{
    //while(1){
    int N;
    cin>>N;
    vector<int> bids;
    int i=0;
    while(i<N)
    {
              int a;
              cin>>a;
              bids.push_back(a);
              i++;
    }
    int reslcm =1;
    for(int i=0;i<N;i++)
    {
            reslcm = lcm(reslcm,bids[i]);
    }
    //cout<<"Got: "<<reslcm<<endl;
    bool flag=true;
    for(int i=0;i<N;i++)
    {
            int tmp = reslcm/bids[i];
            if(tmp==1 || !tmp%2 || !tmp%3 || !tmp%6)
                      continue;
            else
                flag = false;
    }
    if(flag)
       cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    //}
  //  getch();
    return 0;
}


#include<iostream>

using namespace std;

int gcd(int a, int b)
{
	return b ? gcd(b, a%b) : a;
}

int main()
{
	int n;
	cin >> n;
	int p[10010];
	int min1 = 1e9 + 1, min2 = 1e9 + 1;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (p[i] < min1) {
			min2 = min1;
			min1 = p[i];

		}
		else if (p[i] < min2 && p[i] > min1)
			min2 = p[i];
	}
	int t = gcd(min1, min2);
	int fg = 1;
	for (int i = 0; i < n;i++)
		if (p[i] % t != 0) {
			fg = 0;
			break;
		}
		else {
			p[i] /= t;
			if (p[i] % 2 == 0)
				continue;
			else if (p[i] % 3 == 0)
				continue;
			else if (p[i] == 1)
				continue;
			else {
				fg = 0;
				break;
			}
		}
		if (fg == 0)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	return 0;
}


#include<iostream>

using namespace std;

int gcd(int a, int b)
{
	return b ? gcd(b, a%b) : a;
}

int main()
{
	int n;
	cin >> n;
	long long p[10010];
	int min1 = 1e9 + 1, min2 = 1e9 + 1;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (p[i] < min1) {
			min2 = min1;
			min1 = p[i];
		}
		else if (p[i] < min2 && p[i] > min1)
			min2 = p[i];
	}
	int t = gcd(min1, min2);
	int fg = 1;
	for (int i = 0; i < n; i++) {
		if (p[i] % t != 0) {
			fg = 0;
			break;
		}
		else {
			p[i] /= t;
			if (p[i] % 2 == 0)
				continue;
			else if (p[i] % 3 == 0)
				continue;
			else if (p[i] == 1)
				continue;
			else {
				fg = 0;
				break;
			}
		}
	}
	if (fg == 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
		return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main()
{
	int n;
	scanf( "%d", &n);
	for ( int i = 0; i < n; i++){
		scanf( "%d", &a[i]);
		while ( a[i] % 2 == 0){
			a[i] /= 2;
		}
		while ( a[i] % 3 == 0){
			a[i] /= 3;
		}
	}
	int x = a[0], i;
	for ( i = 1; i < n; i++){
		if ( a[i] != x){
			break;
		}
	}
	if ( i == n)
	puts( "Yes");
	else
	puts( "No");
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int a[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        while(a[i]%2==0)a[i]/=2;
        while(a[i]%3==0)a[i]/=3;
    }
    sort(a+1,a+n+1);
    printf("%s\n",(a[1]==a[n] ? "Yes" : "No"));
    return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
long long num[100005];
int main(){
	int n;
	scanf("%d",&n);
	scanf("%I64d",&num[0]);
		while(num[0]%3==0)
			num[0]/=3;
		while(num[0]%2==0)
			num[0]/=2;
	long long x = num[0];
	bool j = true;
	for(int i = 1;i<n;i++){
		scanf("%I64d",&num[i]);
		while(num[i]%3==0)
			num[i]/=3;
		while(num[i]%2==0)
			num[i]/=2;
		if(num[i]!=x){
			j = false;
			break;
		}

	}
	if(j) printf("Yes\n");
	else printf("No\n");

	return 0;
}


// Copyright 2015 © Ayush Garg , B.E. (Hons.) (in COE) , NSIT, Delhi
// All or any part of the code should not be copied without consent
// Since I strictly oppose plagiarism.

#include<bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(i=x;i<y;i++)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define pb push_back

using namespace std;
vector<ll>v;
map<ll,int>m;

int main()
{
    int i,t,n,flag=0;
    ll top,x,y,gcd,Max;
    cin>>n;
    m.clear();
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.pb(x);
    }
    sort(v.begin(),v.end());
    gcd=v[0];
    Max=v[n-1];
    for(i=1;i<n;i++)
    {
        gcd=__gcd(gcd,v[i]);
    }

    queue<ll>q;
    q.push(gcd);
    m[gcd]=1;
    while(!q.empty())
    {
        top=q.front();
        q.pop();
//        debug(top);
        x=2*top;
        y=3*top;
        if(x<=Max && m[x]!=1)
        {
            m[x]=1;
            q.push(x);
        }
        if(y<=Max && m[y]!=1)
        {
            m[y]=1;
            q.push(y);
        }
    }

    for(i=0;i<n;i++)
    {
        x=v[i];
        if(m[x]!=1)
        {
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


// Copyright 2015 © Ayush Garg , B.E. (Hons.) (in COE) , NSIT, Delhi
// All or any part of the code should not be copied without consent
// Since I strictly oppose plagiarism.

#include<bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(i=x;i<y;i++)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define pb push_back

using namespace std;
vector<ll>v;
map<ll,int>m;

ll gcd(ll a,ll b)
{
    if(b==0LL)
        return a;
    return gcd(b,a%b);
}

int main()
{
    int i,t,n,flag=0;
    ll x,y,Max,gcd_,top;
    cin>>n;
    m.clear();
    for(i=0; i<n; i++)
    {
        cin>>x;
        v.pb(x);
    }
    sort(v.begin(),v.end());
    gcd_=v[0];
    for(i=1; i<n; i++)
    {
        gcd_=gcd(gcd_,v[i]);
    }
//    debug(gcd_);
    queue<ll>q;
    m[gcd_]=1;
    q.push(gcd_);
    while(!q.empty())
    {
        top=q.front();
        q.pop();
        x=top*2;
        y=top*3;
        if(m[x]!=1 && x<=Max)
            {
                m[x]=1;
                q.push(x);
            }
        if(m[y]!=1 && y<=Max)
            {
                m[y]=1;
                q.push(y);
            }
    }

    for(i=0; i<n; i++)
    {
        x=v[i];
        if(m[x]!=1)
        {
            if(n==1234)
            cout<<x<<endl;
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


// Copyright 2015 © Ayush Garg , B.E. (Hons.) (in COE) , NSIT, Delhi
// All or any part of the code should not be copied without consent
// Since I strictly oppose plagiarism.

#include<bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(i=x;i<y;i++)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define pb push_back

using namespace std;
vector<ll>v;
map<ll,int>m;

int main()
{
    int i,t,n,flag=0;
    ll top,x,y,gcd,Max;
    cin>>n;
    m.clear();
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.pb(x);
    }
    sort(v.begin(),v.end());
    gcd=v[0];
    Max=v[n-1];
    for(i=1;i<n;i++)
    {
        gcd=__gcd(gcd,v[i]);
    }

    queue<ll>q;
    q.push(gcd);
    m[gcd]=1;
    while(!q.empty())
    {
        top=q.front();
        q.pop();
//        debug(top);
        x=2*top;
        y=3*top;
        if(x<=Max && m[x]!=1)
        {
            m[x]=1;
            q.push(x);
        }
        if(y<=Max && m[y]!=1)
        {
            m[y]=1;
            q.push(y);
        }
    }

    for(i=0;i<n;i++)
    {
        x=v[i];
        if(m[x]!=1)
        {
            if(n==1234)
                cout<<x<<endl;
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


// Copyright 2015 � Ayush Garg , B.E. (Hons.) (in COE) , NSIT, Delhi
// All or any part of the code should not be copied without consent
// Since I strictly oppose plagiarism.

#include<bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(i=x;i<y;i++)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define pb push_back

using namespace std;
vector<ll>v;
map<ll,int>m;

ll gcd(ll a,ll b)
{
    if(b==0LL)
        return a;
    return gcd(b,a%b);
}

void div(ll lcm)
{
    m[lcm]=1;
    if(lcm>0)
    {
        div(lcm/2);
        div(lcm/3);
    }
//    if(lcm<v[0])
//        return;
//    m[lcm]++;
//    if(lcm%2LL==0LL)
//    {
//        div(lcm/2LL);
//    }
//    if(lcm%3LL==0LL)
//        div(lcm/3LL);
    return;
}

int main()
{
    int i,t,n,flag=0;
    ll lcm,x;
    cin>>n;
    m.clear();
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.pb(x);
    }
    sort(v.begin(),v.end());
    lcm=v[0];
    for(i=1;i<n;i++)
    {
        lcm=(lcm*v[i])/gcd(lcm,v[i]);
    }
    div(lcm);

    for(i=0;i<n;i++)
    {
        x=v[i];
        if(m[x]!=1)
        {
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


// Copyright 2015 © Ayush Garg , B.E. (Hons.) (in COE) , NSIT, Delhi
// All or any part of the code should not be copied without consent
// Since I strictly oppose plagiarism.

#include<bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(i=x;i<y;i++)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define pb push_back

using namespace std;
vector<ll>v;
map<ll,int>m;

ll gcd(ll a,ll b)
{
    if(b==0LL)
        return a;
    return gcd(b,a%b);
}

void div(ll lcm)
{
    m[lcm]=1;

    if(lcm>0)
    {
        if(lcm/2>0 && m[lcm/2]!=1)
            div(lcm/2);
        if(lcm/3>0 && m[lcm/3]!=1)
            div(lcm/3);
    }
//    if(lcm<v[0])
//        return;
//    m[lcm]++;
//    if(lcm%2LL==0LL)
//    {
//        div(lcm/2LL);
//    }
//    if(lcm%3LL==0LL)
//        div(lcm/3LL);
    return;
}

int main()
{
    int i,t,n,flag=0;
    ll lcm,x;
    cin>>n;
    m.clear();
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.pb(x);
    }
    sort(v.begin(),v.end());
    lcm=v[0];
    for(i=1;i<n;i++)
    {
        lcm=(lcm*v[i])/gcd(lcm,v[i]);
    }
    div(lcm);

    for(i=0;i<n;i++)
    {
        x=v[i];
        if(m[x]!=1)
        {
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


// Copyright 2015 © Ayush Garg , B.E. (Hons.) (in COE) , NSIT, Delhi
// All or any part of the code should not be copied without consent
// Since I strictly oppose plagiarism.

#include<bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(i=x;i<y;i++)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define pb push_back

using namespace std;
vector<ll>v;
map<ll,int>m;

ll gcd(ll a,ll b)
{
    if(b==0LL)
        return a;
    return gcd(b,a%b);
}

void div(ll lcm)
{
    m[lcm]=1;

    if(lcm>0)
    {
        if(lcm/2>0 && m[lcm/2]!=1)
            div(lcm/2);
        if(lcm/3>0 && m[lcm/3]!=1)
            div(lcm/3);
    }
//    if(lcm<v[0])
//        return;
//    m[lcm]++;
//    if(lcm%2LL==0LL)
//    {
//        div(lcm/2LL);
//    }
//    if(lcm%3LL==0LL)
//        div(lcm/3LL);
    return;
}

int main()
{
    int i,t,n,flag=0;
    ll lcm,x;
    cin>>n;
    m.clear();
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.pb(x);
    }
    sort(v.begin(),v.end());
    lcm=v[0];
    for(i=1;i<n;i++)
    {
        lcm=(lcm*v[i])/gcd(lcm,v[i]);
    }
    div(lcm);

    for(i=0;i<n;i++)
    {
        x=v[i];
        if(m[x]!=1)
        {
            if(n==1234)
                cout<<x<<endl;
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


// Copyright 2015 � Ayush Garg , B.E. (Hons.) (in COE) , NSIT, Delhi
// All or any part of the code should not be copied without consent
// Since I strictly oppose plagiarism.

#include<bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(i=x;i<y;i++)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define pb push_back

using namespace std;
vector<ll>v;
map<ll,int>m;

ll gcd(ll a,ll b)
{
    if(b==0LL)
        return a;
    return gcd(b,a%b);
}

void div(ll lcm)
{
    m[lcm]++;
    if(lcm%2LL==0LL)
    {
        div(lcm/2LL);
    }
    if(lcm%3LL==0LL)
        div(lcm/3LL);

    return;
}

int main()
{
    int i,t,n,flag=0;
    ll lcm,x;
    cin>>n;
    m.clear();
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.pb(x);
        m[x]=1;
    }
    sort(v.begin(),v.end());
    lcm=v[0];
    for(i=1;i<n;i++)
    {
        lcm=(lcm*v[i])/gcd(lcm,v[i]);
    }
    div(lcm);

    for(i=0;i<n;i++)
    {
        x=v[i];
        if(m[x]<2)
        {
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


// Copyright 2015 � Ayush Garg , B.E. (Hons.) (in COE) , NSIT, Delhi
// All or any part of the code should not be copied without consent
// Since I strictly oppose plagiarism.

#include<bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(i=x;i<y;i++)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define pb push_back

using namespace std;
vector<ll>v;

ll x,y;
int flag;

ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

void div(ll lcm)
{
//    debug(lcm);
    if(lcm<min(x,y))
        return;
    if(lcm==x)
        flag++;
    if(lcm==y)
        flag++;

    if(lcm%2==0)
    {
        div(lcm/2);
    }
    if(lcm%3==0)
        div(lcm/3);

    return;
}

int main()
{
    int i,t,n;
    ll lcm,g;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.pb(x);
    }
    sort(v.begin(),v.end());
    for(i=1;i<n;i++)
    {
        x=v[i-1];
        y=v[i];
        flag=0;
        lcm=(x*y)/gcd(x,y);
        div(lcm);
//        debug(lcm);
//        debug(flag);
        if(flag<2)
            break;
        else
            v.push_back(lcm);

    }
    if(flag<2)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


/****** BISMILLAH HIR RAHMANIR RAHIM ******/

/*

"For indeed, with hardship [will be] ease. Indeed, with hardship [will be] ease."

-- Surah Inshirah (94:5-6)

And We will surely test you with something of fear and hunger and a loss of wealth and lives and fruits, but give good tidings to the patient,
Who, when disaster strikes them, say, "Indeed we belong to Allah , and indeed to Him we will return."
Those are the ones upon whom are blessings from their Lord and mercy. And it is those who are the [rightly] guided.

-- Surah Al-Baqarah (2:155-157)

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<"\n"
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=b; i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(j,0,v.size()) cout<<v[j]<<" "; cout<<endl
#define endl "\n"

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline ll power(ll a, ll b)
{
	ll multiply=1;
	FOR(i,0,b)
	{
		multiply*=a;
	}
	return multiply;
}

/****** END OF HEADER ******/

int n;
ll a[100005], b[100005], c[100005];

bool Power(ll x, ll y)
{
	while(x>0)
	{
		if(x%y>1) return false;
		x/=y;
	}
	return true;
}

int main()
{
	// ios_base::sync_with_stdio(0);
	// cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);

	cin>>n;

	ll x=0, y=0, z=0;
	ll in;

	FOR(i,0,n)
	{
		cin>>in;

		a[i]=in*6;
		b[i]=in*2;
		c[i]=in*3;

		x=max(x,a[i]);
		y=max(y,b[i]);
		z=max(z,c[i]);
	}

	bool flag1=true, flag2=true, flag3=true;

	FOR(i,0,n)
	{
		if(x%a[i])
		{
			flag1=false;
			break;
		}
		else
		{
			ll r=x/a[i];

			if(Power(r,6)==false)
			{
				flag1=false;
				break;
			}
		}
	}

	FOR(i,0,n)
	{
		if(y%b[i])
		{
			flag2=false;
			break;
		}
		else
		{
			ll r=y/b[i];

			if(Power(r,2)==false)
			{
				flag2=false;
				break;
			}
		}
	}

	FOR(i,0,n)
	{
		if(z%c[i])
		{
			flag3=false;
			break;
		}
		else
		{
			ll r=z/c[i];

			if(Power(r,3)==false)
			{
				flag3=false;
				break;
			}
		}
	}

	if(flag1 || flag2 || flag3)
		prnt("Yes");
	else
		prnt("No");

	return 0;
}


/****** BISMILLAH HIR RAHMANIR RAHIM ******/

/*

"For indeed, with hardship [will be] ease. Indeed, with hardship [will be] ease."

-- Surah Inshirah (94:5-6)

And We will surely test you with something of fear and hunger and a loss of wealth and lives and fruits, but give good tidings to the patient,
Who, when disaster strikes them, say, "Indeed we belong to Allah , and indeed to Him we will return."
Those are the ones upon whom are blessings from their Lord and mercy. And it is those who are the [rightly] guided.

-- Surah Al-Baqarah (2:155-157)

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<"\n"
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=b; i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(j,0,v.size()) cout<<v[j]<<" "; cout<<endl
#define endl "\n"

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline ll power(ll a, ll b)
{
	ll multiply=1;
	FOR(i,0,b)
	{
		multiply*=a;
	}
	return multiply;
}

/****** END OF HEADER ******/

int n;
ll a[100005], b[100005], c[100005];

bool Power(ll x)
{
	while(x>0)
	{
		if(x%6==0) x/=6;
		else if(x%2==0) x/=2;
		else if(x%3==0) x/=3;
		else if(x==1) return true;
		else return false;
	}
	return true;
}

int main()
{
	// ios_base::sync_with_stdio(0);
	// cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);

	cin>>n;

	ll x=0, y=0, z=0;
	ll in, Mx=0;

	FOR(i,0,n)
	{
		cin>>in;
		a[i]=in;
		Mx=max(a[i],Mx);
	}

	bool flag=true;

	FOR(i,0,n)
	{
		if(Mx%a[i])
		{
			flag=false;
			break;
		}
		else
		{
			flag=Power(Mx/a[i]);
			if(!flag) break;
		}
	}

	if(flag)
		prnt("Yes");
	else
		prnt("No");

	return 0;
}


/****** BISMILLAH HIR RAHMANIR RAHIM ******/

/*

"For indeed, with hardship [will be] ease. Indeed, with hardship [will be] ease."

-- Surah Inshirah (94:5-6)

And We will surely test you with something of fear and hunger and a loss of wealth and lives and fruits, but give good tidings to the patient,
Who, when disaster strikes them, say, "Indeed we belong to Allah , and indeed to Him we will return."
Those are the ones upon whom are blessings from their Lord and mercy. And it is those who are the [rightly] guided.

-- Surah Al-Baqarah (2:155-157)

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<"\n"
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=b; i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(j,0,v.size()) cout<<v[j]<<" "; cout<<endl
#define endl "\n"

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline ll power(ll a, ll b)
{
	ll multiply=1;
	FOR(i,0,b)
	{
		multiply*=a;
	}
	return multiply;
}

/****** END OF HEADER ******/

int n;
ll a[100005], b[100005], c[100005];

int main()
{
	// ios_base::sync_with_stdio(0);
	// cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);

	cin>>n;

	ll x=0, y=0, z=0;
	ll in;

	FOR(i,0,n)
	{
		cin>>in;

		a[i]=in*6;
		b[i]=in*2;
		c[i]=in*3;

		x=max(x,a[i]);
		y=max(y,b[i]);
		z=max(z,c[i]);
	}

	bool flag1=true, flag2=true, flag3=true;

	FOR(i,0,n)
	{
		if(x%a[i]) flag1=false;
	}

	FOR(i,0,n)
	{
		if(y%b[i]) flag2=false;
	}

	FOR(i,0,n)
	{
		if(z%c[i]) flag3=false;
	}

	if(flag1 && flag2 && flag3)
		prnt("Yes");
	else
		prnt("No");

	return 0;
}


/****** BISMILLAH HIR RAHMANIR RAHIM ******/

/*

"For indeed, with hardship [will be] ease. Indeed, with hardship [will be] ease."

-- Surah Inshirah (94:5-6)

And We will surely test you with something of fear and hunger and a loss of wealth and lives and fruits, but give good tidings to the patient,
Who, when disaster strikes them, say, "Indeed we belong to Allah , and indeed to Him we will return."
Those are the ones upon whom are blessings from their Lord and mercy. And it is those who are the [rightly] guided.

-- Surah Al-Baqarah (2:155-157)

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<"\n"
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=b; i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(j,0,v.size()) cout<<v[j]<<" "; cout<<endl
#define endl "\n"

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline ll power(ll a, ll b)
{
	ll multiply=1;
	FOR(i,0,b)
	{
		multiply*=a;
	}
	return multiply;
}

/****** END OF HEADER ******/

int n;
ll a[100005], b[100005], c[100005];

bool Power(ll x)
{
	while(x>0)
	{
		if(x%6==0) x/=6;
		else if(x%2==0) x/=2;
		else if(x%3==0) x/=3;
		else if(x==1) return true;
		else return false;
	}
	return true;
}

int main()
{
	// ios_base::sync_with_stdio(0);
	// cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);

	cin>>n;

	ll x=0, y=0, z=0;
	ll in, Mx=0;

	FOR(i,0,n)
	{
		cin>>in;
		a[i]=in;
		Mx=max(a[i],Mx);
	}

	bool flag=true;

	FOR(i,0,n)
	{
		if(Mx%a[i]) flag=false;
		else
			flag=Power(Mx/a[i]);
	}

	if(flag)
		prnt("Yes");
	else
		prnt("No");

	return 0;
}


/****** BISMILLAH HIR RAHMANIR RAHIM ******/

/*

"For indeed, with hardship [will be] ease. Indeed, with hardship [will be] ease."

-- Surah Inshirah (94:5-6)

And We will surely test you with something of fear and hunger and a loss of wealth and lives and fruits, but give good tidings to the patient,
Who, when disaster strikes them, say, "Indeed we belong to Allah , and indeed to Him we will return."
Those are the ones upon whom are blessings from their Lord and mercy. And it is those who are the [rightly] guided.

-- Surah Al-Baqarah (2:155-157)

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<"\n"
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=b; i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(j,0,v.size()) cout<<v[j]<<" "; cout<<endl
#define endl "\n"

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline ll power(ll a, ll b)
{
	ll multiply=1;
	FOR(i,0,b)
	{
		multiply*=a;
	}
	return multiply;
}

/****** END OF HEADER ******/

int n;
ll a[100005], b[100005], c[100005];

int main()
{
	// ios_base::sync_with_stdio(0);
	// cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);

	cin>>n;

	ll x=0, y=0, z=0;
	ll in;

	FOR(i,0,n)
	{
		cin>>in;

		a[i]=in*6;
		b[i]=in*2;
		c[i]=in*3;

		x=max(x,a[i]);
		y=max(y,b[i]);
		z=max(z,c[i]);
	}

	bool flag1=true, flag2=true, flag3=true;

	FOR(i,0,n)
	{
		if(x%a[i]) flag1=false;
	}

	FOR(i,0,n)
	{
		if(y%b[i]) flag2=false;
	}

	FOR(i,0,n)
	{
		if(z%c[i]) flag3=false;
	}

	if(flag1 || flag2 || flag3)
		prnt("Yes");
	else
		prnt("No");

	return 0;
}


/****** BISMILLAH HIR RAHMANIR RAHIM ******/

/*

"For indeed, with hardship [will be] ease. Indeed, with hardship [will be] ease."

-- Surah Inshirah (94:5-6)

And We will surely test you with something of fear and hunger and a loss of wealth and lives and fruits, but give good tidings to the patient,
Who, when disaster strikes them, say, "Indeed we belong to Allah , and indeed to Him we will return."
Those are the ones upon whom are blessings from their Lord and mercy. And it is those who are the [rightly] guided.

-- Surah Al-Baqarah (2:155-157)

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<"\n"
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=b; i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(j,0,v.size()) cout<<v[j]<<" "; cout<<endl
#define endl "\n"

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline ll power(ll a, ll b)
{
	ll multiply=1;
	FOR(i,0,b)
	{
		multiply*=a;
	}
	return multiply;
}

/****** END OF HEADER ******/

int n, a[100005];

int main()
{
	// ios_base::sync_with_stdio(0);
	// cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);

	cin>>n;

	FOR(i,0,n)
	{
		cin>>a[i];
	}

	FOR(i,0,n)
	{
		while(a[i]%2==0) a[i]/=2;
		while(a[i]%3==0) a[i]/=3;
	}

	FOR(i,0,n)
	{
		if(a[0]!=a[i])
		{
			prnt("No");
			return 0;
		}
	}

	prnt("Yes");

	return 0;
}


/****** BISMILLAH HIR RAHMANIR RAHIM ******/

/*

"For indeed, with hardship [will be] ease. Indeed, with hardship [will be] ease."

-- Surah Inshirah (94:5-6)

And We will surely test you with something of fear and hunger and a loss of wealth and lives and fruits, but give good tidings to the patient,
Who, when disaster strikes them, say, "Indeed we belong to Allah , and indeed to Him we will return."
Those are the ones upon whom are blessings from their Lord and mercy. And it is those who are the [rightly] guided.

-- Surah Al-Baqarah (2:155-157)

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<"\n"
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=b; i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(j,0,v.size()) cout<<v[j]<<" "; cout<<endl
#define endl "\n"

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline ll power(ll a, ll b)
{
	ll multiply=1;
	FOR(i,0,b)
	{
		multiply*=a;
	}
	return multiply;
}

/****** END OF HEADER ******/

int n;
ll a[100005], b[100005], c[100005];

int main()
{
	// ios_base::sync_with_stdio(0);
	// cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);

	cin>>n;

	ll x=0, y=0, z=0;

	FOR(i,0,n)
	{
		cin>>a[i];

		a[i]=a[i]*6;
		b[i]=a[i]*2;
		c[i]=a[i]*3;

		x=max(x,a[i]);
		y=max(y,b[i]);
		z=max(z,c[i]);
	}

	bool flag1=true, flag2=true, flag3=true;

	FOR(i,0,n)
	{
		if(x%a[i]) flag1=false;
	}

	FOR(i,0,n)
	{
		if(y%b[i]) flag2=false;
	}

	FOR(i,0,n)
	{
		if(z%c[i]) flag3=false;
	}

	if(flag1 || flag2 || flag3)
		prnt("Yes");
	else
		prnt("No");

	return 0;
}


/****** BISMILLAH HIR RAHMANIR RAHIM ******/

/*

"For indeed, with hardship [will be] ease. Indeed, with hardship [will be] ease."

-- Surah Inshirah (94:5-6)

And We will surely test you with something of fear and hunger and a loss of wealth and lives and fruits, but give good tidings to the patient,
Who, when disaster strikes them, say, "Indeed we belong to Allah , and indeed to Him we will return."
Those are the ones upon whom are blessings from their Lord and mercy. And it is those who are the [rightly] guided.

-- Surah Al-Baqarah (2:155-157)

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<"\n"
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=b; i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(j,0,v.size()) cout<<v[j]<<" "; cout<<endl
#define endl "\n"

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline ll power(ll a, ll b)
{
	ll multiply=1;
	FOR(i,0,b)
	{
		multiply*=a;
	}
	return multiply;
}

/****** END OF HEADER ******/

int n;
ll a[100005], b[100005], c[100005];

bool Power(ll x, ll y)
{
	while(x>0)
	{
		if(x%6==0) x/=6;
		else if(x%2==0) x/=2;
		else if(x%3==0) x/=3;
		else if(x==1) return true;
		else return false;
	}
	return true;
}

int main()
{
	// ios_base::sync_with_stdio(0);
	// cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);

	cin>>n;

	ll x=0, y=0, z=0;
	ll in;

	FOR(i,0,n)
	{
		cin>>in;

		a[i]=in*6;
		b[i]=in*2;
		c[i]=in*3;

		x=max(x,a[i]);
		y=max(y,b[i]);
		z=max(z,c[i]);
	}

	bool flag1=true, flag2=true, flag3=true;

	FOR(i,0,n)
	{
		if(x%a[i])
		{
			flag1=false;
			break;
		}
		else
		{
			ll r=x/a[i];

			if(Power(r,6)==false)
			{
				flag1=false;
				break;
			}
		}
	}

	FOR(i,0,n)
	{
		if(y%b[i])
		{
			flag2=false;
			break;
		}
		else
		{
			ll r=y/b[i];

			if(Power(r,2)==false)
			{
				flag2=false;
				break;
			}
		}
	}

	FOR(i,0,n)
	{
		if(z%c[i])
		{
			flag3=false;
			break;
		}
		else
		{
			ll r=z/c[i];

			if(Power(r,3)==false)
			{
				flag3=false;
				break;
			}
		}
	}

	if(flag1 || flag2 || flag3)
		prnt("Yes");
	else
		prnt("No");

	return 0;
}


#include<iostream>
#include<math.h>

using namespace std;

int powerof3(long long int num)
{
    int i=0;
    while(1)
    {
        if(pow(3,i)==num)
            return 1;
        else if(pow(3,i)>num)
            return 0;
        i++;
    }
}

int powerof2(long long int num)
{
    int i=0;
    while(1)
    {
        if(pow(2,i)==num)
            return 1;
        else if(pow(2,i)>num)
            return 0;
        i++;
    }
}

int divisibilityby6(long long int num)
{
    int d,e;
    while(num)
    {
        if(num%6!=0)
        {
            if(num==1)
                return 1;
            d=powerof3(num);
            e=powerof2(num);
            if(d==0 && e==0)
                return 0;
            else
                return 1;
        }
        num/=6;
    }
}

int main()
{
    long long int n,i,product=1,d,e,f,flag=0,x,y,a,b,lcm,gcd,t;
    cin>>n;
    long long int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    x=arr[0];
    y=arr[1];
    for(i=1;i<n;i++)
    {
        a = x;
        b = y;
        while (b != 0)
        {
            t = b;
            b = a % b;
            a = t;
        }
        gcd = a;
        lcm = (x*y)/gcd;
        x=lcm;
        y=arr[i+1];
    }
    //cout<<x<<"\n";
    for(i=0;i<n;i++)
    {
        d=divisibilityby6(x/arr[i]);
        e=powerof3(x/arr[i]);
        f=powerof2(x/arr[i]);
        if(d==0 && e==0 && f==0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


#include<iostream>
#include<math.h>

using namespace std;

int divisibilityby6(long long int num)
{
    if(num%6==0)
        return 1;
    else
        return 0;
}

int powerof3(long long int num)
{
    int i=0;
    while(1)
    {
        if(pow(3,i)==num)
            return 1;
        else if(pow(3,i)>num)
            return 0;
        i++;
    }
}

int powerof2(long long int num)
{
    int i=0;
    while(1)
    {
        if(pow(2,i)==num)
            return 1;
        else if(pow(2,i)>num)
            return 0;
        i++;
    }
}

int main()
{
    long long int n,i,product=1,d,e,f,flag=0;
    cin>>n;
    long long int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        product*=arr[i];
    }
    d=arr[0];
    for(i=1;i<n;i++)
    {
        if(d!=arr[i])
        {
            flag=1;
            break;
        }
    }
    if(flag==0)
    {
        cout<<"Yes";
        return 0;
    }
    for(i=0;i<n;i++)
    {
        d=divisibilityby6(product/arr[i]);
        e=powerof3(product/arr[i]);
        f=powerof2(product/arr[i]);
        if(d==0 && e==0 && f==0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


#include<iostream>

using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        while(arr[i]%2==0)
            arr[i]/=2;
        while(arr[i]%3==0)
            arr[i]/=3;
    }
    for(i=1;i<n;i++)
    {
        if(arr[i]!=arr[i-1])
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


#include<iostream>
#include<math.h>

using namespace std;

int divisibilityby6(long long int num)
{
    if(num%6==0)
        return 1;
    else
        return 0;
}

int powerof3(long long int num)
{
    int i=0;
    while(1)
    {
        if(pow(3,i)==num)
            return 1;
        else if(pow(3,i)>num)
            return 0;
        i++;
    }
}

int powerof2(long long int num)
{
    int i=0;
    while(1)
    {
        if(pow(2,i)==num)
            return 1;
        else if(pow(2,i)>num)
            return 0;
        i++;
    }
}

int main()
{
    long long int n,i,product=1,d,e,f;
    cin>>n;
    long long int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        product*=arr[i];
    }
    for(i=0;i<n;i++)
    {
        d=divisibilityby6(product/arr[i]);
        e=powerof3(product/arr[i]);
        f=powerof2(product/arr[i]);
        if(d==0 && e==0 && f==0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


#include<iostream>
#include<math.h>

using namespace std;

int divisibilityby6(long long int num)
{
    if(num%6==0)
        return 1;
    else
        return 0;
}

int powerof3(long long int num)
{
    int i=0;
    while(1)
    {
        if(pow(3,i)==num)
            return 1;
        else if(pow(3,i)>num)
            return 0;
        i++;
    }
}

int powerof2(long long int num)
{
    int i=0;
    while(1)
    {
        if(pow(2,i)==num)
            return 1;
        else if(pow(2,i)>num)
            return 0;
        i++;
    }
}

int main()
{
    long long int n,i,product=1,d,e,f,flag=0,x,y,a,b,lcm,gcd,t;
    cin>>n;
    long long int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    x=arr[0];
    y=arr[1];
    for(i=1;i<n;i++)
    {
        a = x;
        b = y;
        while (b != 0)
        {
            t = b;
            b = a % b;
            a = t;
        }
        gcd = a;
        lcm = (x*y)/gcd;
        x=lcm;
        y=arr[i+1];
    }
    for(i=0;i<n;i++)
    {
        d=divisibilityby6(x/arr[i]);
        e=powerof3(x/arr[i]);
        f=powerof2(x/arr[i]);
        if(d==0 && e==0 && f==0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


#include<iostream>
#include<math.h>

using namespace std;

int powerof3(long long int num)
{
    int i=0;
    while(1)
    {
        if(pow(3,i)==num)
            return 1;
        else if(pow(3,i)>num)
            return 0;
        i++;
    }
}

int powerof2(long long int num)
{
    int i=0;
    while(1)
    {
        if(pow(2,i)==num)
            return 1;
        else if(pow(2,i)>num)
            return 0;
        i++;
    }
}

int divisibilityby6(long long int num)
{
    int d,e;
    while(num)
    {
        if(num%6!=0)
        {
            d=powerof3(num);
            e=powerof2(num);
            if(d==0 && e==0)
                return 0;
        }
        num/=6;
    }
    return 1;
}

int main()
{
    long long int n,i,product=1,d,e,f,flag=0,x,y,a,b,lcm,gcd,t;
    cin>>n;
    long long int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    x=arr[0];
    y=arr[1];
    for(i=1;i<n;i++)
    {
        a = x;
        b = y;
        while (b != 0)
        {
            t = b;
            b = a % b;
            a = t;
        }
        gcd = a;
        lcm = (x*y)/gcd;
        x=lcm;
        y=arr[i+1];
    }
    //cout<<x<<"\n";
    for(i=0;i<n;i++)
    {
        d=divisibilityby6(x/arr[i]);
        e=powerof3(x/arr[i]);
        f=powerof2(x/arr[i]);
        if(d==0 && e==0 && f==0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


/*Author :usedrose  */
/*Created Time :2015/8/30 1:20:31*/
/*File Name :2.cpp*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
#define MAXN 1110
#define MAXM 100110
#define OK cout << "ok" << endl;
#define o(a) cout << #a << " = " << a << endl
#define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
using namespace std;
typedef long long LL;

LL a[222222];
int n;

int main()
{
	cin >> n;
	for (int i = 1;i <= n; ++ i) cin >> a[i];
    LL	g = a[1];
	for (int i = 2;i <= n; ++ i)
		g = __gcd(a[i], g);
	bool ok = true;
	for (int i = 1;i <= n; ++ i)
		a[i] /= g;
	for (int i = 1;i <= n; ++ i){
		if ((a[i]%2 != 0) && (a[i]%3 != 0)) ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


/*Author :usedrose  */
/*Created Time :2015/8/30 1:20:31*/
/*File Name :2.cpp*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
#define MAXN 1110
#define MAXM 100110
#define OK cout << "ok" << endl;
#define o(a) cout << #a << " = " << a << endl
#define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
using namespace std;
typedef long long LL;

LL a[222222];
int n;
LL p[222222];

void init()
{
	for (int i = 2;i <= sqrt(222222); ++ i)
		if (!p[i])
			for (int j = 2*i; j< 222222; j += i)
				p[j] = 1;
}

int main()
{
	init();
	cin >> n;
	for (int i = 1;i <= n; ++ i) cin >> a[i];
    LL	g = a[1];
	for (int i = 2;i <= n; ++ i)
		g = __gcd(a[i], g);
	bool ok = true;
	for (int i = 1;i <= n; ++ i)
		a[i] /= g;
	for (int i = 1;i <= n; ++ i){
		if (a[i] == 1 || a[i] == 2 || a[i] == 3) continue;
		if (p[a[i]] == 0) ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


/*Author :usedrose  */
/*Created Time :2015/8/30 1:20:31*/
/*File Name :2.cpp*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
#define MAXN 1110
#define MAXM 100110
#define OK cout << "ok" << endl;
#define o(a) cout << #a << " = " << a << endl
#define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
using namespace std;
typedef long long LL;

int gcd(int a, int b)
{
	return b == 0?a:gcd(b,a%b);
}
int a[22222];
int n;

int main()
{
	cin >> n;
	for (int i = 1;i <= n; ++ i) cin >> a[i];
	int g = a[1];
	for (int i = 2;i <= n; ++ i)
		g = __gcd(a[i], g);
	bool ok = true;
	for (int i = 1;i <= n; ++ i){
		if (( (a[i]/g)%2 == 0) || ((a[i]/g)%3 == 0)) continue;
		ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


/*Author :usedrose  */
/*Created Time :2015/8/30 1:20:31*/
/*File Name :2.cpp*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
#define MAXN 1110
#define MAXM 100110
#define OK cout << "ok" << endl;
#define o(a) cout << #a << " = " << a << endl
#define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
using namespace std;
typedef long long LL;

LL a[22222];
int n;

int main()
{
	cin >> n;
	for (int i = 1;i <= n; ++ i) cin >> a[i];
    LL	g = a[1];
	for (int i = 2;i <= n; ++ i)
		g = __gcd(a[i], g);
	bool ok = true;
	for (int i = 1;i <= n; ++ i)
		a[i]/=g;
	for (int i = 1;i <= n; ++ i){
		if ((a[i]%2 != 0) && (a[i]%3 != 0)) ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


/*Author :usedrose  */
/*Created Time :2015/8/30 1:20:31*/
/*File Name :2.cpp*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
#define MAXN 1110
#define MAXM 100110
#define OK cout << "ok" << endl;
#define o(a) cout << #a << " = " << a << endl
#define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
using namespace std;
typedef long long LL;

LL a[222222];
int n;
LL p[222222];

void init()
{
	for (int i = 2;i <= sqrt(222222); ++ i)
		if (!p[i])
			for (int j = 2*i; j< 222222; j += i)
				p[j] = 1;
}

int main()
{
	init();
	cin >> n;
	for (int i = 1;i <= n; ++ i) cin >> a[i];
    LL	g = a[1];
	for (int i = 2;i <= n; ++ i) {
		g = __gcd(a[i], g);
	}
	bool ok = true;
	for (int i = 1;i <= n; ++ i)
		a[i] /= g;
	for (int i = 1;i <= n; ++ i){
		while (a[i]%2 == 0) a[i]/=2;
		while (a[i]%3 == 0) a[i]/=3;
		if (a[i] == 1 || a[i] == 2 || a[i] == 3) continue;
		if (p[a[i]] == 0) ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


/*Author :usedrose  */
/*Created Time :2015/8/31 20:42:15*/
/*File Name :2.cpp*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
#define MAXN 1110
#define MAXM 100110
#define OK cout << "ok" << endl;
#define o(a) cout << #a << " = " << a << endl
#define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
using namespace std;
typedef long long LL;

int a[MAXM];
int n;

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


/*Author :usedrose  */
/*Created Time :2015/8/30 1:20:31*/
/*File Name :2.cpp*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
#define MAXN 1110
#define MAXM 100110
#define OK cout << "ok" << endl;
#define o(a) cout << #a << " = " << a << endl
#define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
using namespace std;
typedef long long LL;

LL a[222222];
int n;
LL p[222222];

void init()
{
	for (int i = 2;i <= sqrt(111111); ++ i)
		if (!p[i])
			for (int j = 2*i; j< 111111; j += i)
				p[j] = 1;
}

int main()
{
	init();
	cin >> n;
	for (int i = 1;i <= n; ++ i) cin >> a[i];
    LL	g = a[1];
	for (int i = 2;i <= n; ++ i) {
		g = __gcd(a[i], g);
	}
	bool ok = true;
	for (int i = 1;i <= n; ++ i)
		a[i] /= g;
	for (int i = 1;i <= n; ++ i){
		while (a[i]%2 == 0) a[i]/=2;
		while (a[i]%3 == 0) a[i]/=3;
		if (a[i] == 1 || a[i] == 2 || a[i] == 3) continue;
		if (p[a[i]] == 0) ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


/*Author :usedrose  */
/*Created Time :2015/8/30 1:20:31*/
/*File Name :2.cpp*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
#define MAXN 1110
#define MAXM 100110
#define OK cout << "ok" << endl;
#define o(a) cout << #a << " = " << a << endl
#define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
using namespace std;
typedef long long LL;

LL a[222222];
int n;
LL p[222222];

bool is(int x)
{
	for (int i = 2;i <= sqrt(x+1); ++ i) {
		if (x%i == 0) return false;
	}
	return true;
}

int main()
{
	cin >> n;
	for (int i = 1;i <= n; ++ i) cin >> a[i];
    LL	g = a[1];
	for (int i = 2;i <= n; ++ i) {
		g = __gcd(a[i], g);
	}
	bool ok = true;
	for (int i = 1;i <= n; ++ i)
		a[i] /= g;
	for (int i = 1;i <= n; ++ i){
		while (a[i]%2 == 0) a[i]/=2;
		while (a[i]%3 == 0) a[i]/=3;
		if (a[i] == 1 || a[i] == 2 || a[i] == 3) continue;
		if (is(a[i])) {
			ok = false;
			break;
		}
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


/*Author :usedrose  */
/*Created Time :2015/8/30 1:20:31*/
/*File Name :2.cpp*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
#define MAXN 1110
#define MAXM 100110
#define OK cout << "ok" << endl;
#define o(a) cout << #a << " = " << a << endl
#define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
using namespace std;
typedef long long LL;

LL a[222222];
int n;

int main()
{
	cin >> n;
	for (int i = 1;i <= n; ++ i) cin >> a[i];
    LL	g = a[1];
	for (int i = 2;i <= n; ++ i)
		g = __gcd(a[i], g);
	bool ok = true;
	for (int i = 1;i <= n; ++ i)
		a[i] /= g;
	for (int i = 1;i <= n; ++ i){
		if  (__gcd(a[i], 6LL) == 1) ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


/*Author :usedrose  */
/*Created Time :2015/8/30 1:20:31*/
/*File Name :2.cpp*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
#define MAXN 1110
#define MAXM 100110
#define OK cout << "ok" << endl;
#define o(a) cout << #a << " = " << a << endl
#define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
using namespace std;
typedef long long LL;

LL a[222222];
int n;

int main()
{
	cin >> n;
	for (int i = 1;i <= n; ++ i) cin >> a[i];
    LL	g = a[1];
	for (int i = 2;i <= n; ++ i)
		g = __gcd(a[i], g);
	bool ok = true;
	for (int i = 1;i <= n; ++ i)
		a[i] /= g;
	for (int i = 1;i <= n; ++ i){
		if  (__gcd(a[i], 6LL) == 1 && a[i] != 1) ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define PF           printf
#define SF(n)        scanf("%d", &n)
#define SFF(a,b)     scanf("%d %d", &a, &b)
#define SFFF(a,b,c)  scanf("%d %d %d", &a, &b, &c)
#define INF_I        2147483647    //max limit
#define INF          1999999999
#define PB           push_back
#define MEM(n, val)  memset((n), val, sizeof(n))
#define F            first
#define S            second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ALL(c)       c.begin(), c.end()
#define BOOST        std::ios_base::sync_with_stdio(false);
#define INP          freopen("in.txt", "r", stdin);
#define OUT          freopen("out.txt", "w", stdout);
#define MP           make_pair
#define INIT_RAND    srand(time(NULL))
#define MOD          1000000007
#define A_SZ         1000000
template <class T>
inline std::string to_string (const T& t)
{
    std::stringstream ss;
    ss << t;
    return ss.str();
}

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef priority_queue<int> P_Q;

#define   sz 200005
int a[sz];
int n;
int main()  {
    BOOST;
    cin  >> n;
    FOR(i, 0, n-1) cin >> a[i];

    sort(a, a+n);
    int lol = a[n-1];
    int f = 0;

    FOR(i, 0, n-1) {
        if((lol % (a[i]*2)) == 0 || (lol % (a[i] * 3)) == 0 || lol == a[i] || (lol % (a[i]*6)) == 0 ) continue;
        else {
            f = 1;
            break;
        }
    }
    if(f) cout<<"No"<<endl;
    else cout<<"Yes" << endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define PF           printf
#define SF(n)        scanf("%d", &n)
#define SFF(a,b)     scanf("%d %d", &a, &b)
#define SFFF(a,b,c)  scanf("%d %d %d", &a, &b, &c)
#define INF_I        2147483647    //max limit
#define INF          1999999999
#define PB           push_back
#define MEM(n, val)  memset((n), val, sizeof(n))
#define F            first
#define S            second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ALL(c)       c.begin(), c.end()
#define BOOST        std::ios_base::sync_with_stdio(false);
#define INP          freopen("in.txt", "r", stdin);
#define OUT          freopen("out.txt", "w", stdout);
#define MP           make_pair
#define INIT_RAND    srand(time(NULL))
#define MOD          1000000007
#define A_SZ         1000000
template <class T>
inline std::string to_string (const T& t)
{
    std::stringstream ss;
    ss << t;
    return ss.str();
}

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef priority_queue<int> P_Q;

#define   sz 200005
int a[sz];
int n;
int main()  {
    BOOST;
    cin  >> n;
    FOR(i, 0, n-1) {
        cin >> a[i];
        while(a[i]%2==0 && a[i] !=0) a[i]/=2;
        while(a[i]%3==0 && a[i] !=0) a[i]/=3;
    }
    int f = 0;
    FOR(i, 1, n-1) {
            if(a[i] != a[i-1]) {
                f = 1;
                break;
            }
        }

    if(f) cout<<"No"<<endl;
    else cout<<"Yes" << endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define PF           printf
#define SF(n)        scanf("%d", &n)
#define SFF(a,b)     scanf("%d %d", &a, &b)
#define SFFF(a,b,c)  scanf("%d %d %d", &a, &b, &c)
#define INF_I        2147483647    //max limit
#define INF          1999999999
#define PB           push_back
#define MEM(n, val)  memset((n), val, sizeof(n))
#define F            first
#define S            second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ALL(c)       c.begin(), c.end()
#define BOOST        std::ios_base::sync_with_stdio(false);
#define INP          freopen("in.txt", "r", stdin);
#define OUT          freopen("out.txt", "w", stdout);
#define MP           make_pair
#define INIT_RAND    srand(time(NULL))
#define MOD          1000000007
#define A_SZ         1000000
template <class T>
inline std::string to_string (const T& t)
{
    std::stringstream ss;
    ss << t;
    return ss.str();
}

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef priority_queue<int> P_Q;

#define   sz 200005
int a[sz];
int n;
int main()  {
    BOOST;
    cin  >> n;
    FOR(i, 0, n-1) cin >> a[i];

    sort(a, a+n);
    int lol = a[n-1];
    int f = 0;

    FOR(i, 0, n-1) {
        if( lol%a[i] != 0) f = 1;
    }
    if(f) cout<<"No"<<endl;
    else cout<<"Yes" << endl;
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
int a[100100];

int solve(){
    int flag1 = 0,flag2 = 0;
    for(int i = 1; i < n; i++){
        if(a[i]<a[i+1]) flag1 = 1;
        if(a[i]>a[i+1]) flag2 = 1;
    }
    if(flag1&&flag2) return 0;
    return 1;
}

int main(){
    scanf("%d",&n);
    int maxn = 0,minn = 0,maxp = 1,minp = 1;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]);
    if(n <= 2) {
        printf("-1\n");
        return 0;
    }
    maxn = a[1];
    minn = a[1];
    for(int i = 2; i <= n; i++){
        if(maxn < a[i]){
            maxn = a[i];
            maxp = i;
        }
        if(minn > a[i]){
            minn = a[i];
            minp = i;
        }
    }
    if(n < 100){
        for(int i = 1; i <= n; i++)
            for(int j = i+1; j <= n; j++)
                if(a[i]!=a[j]){
                    swap(a[i],a[j]);
                    if(solve()){
                        printf("%d %d\n",i,j);
                        return 0;
                    }
                    swap(a[i],a[j]);
                }
    }
    //printf("%d %d\n",minp,maxp);
    for(int i = 2; i < n; i++){
        swap(a[i],a[maxp]);
        a[0] = maxn-1;
        if(maxn>a[i-1]&&maxn >a[i+1]&&maxn!=a[maxp]){
            printf("%d %d\n",i,maxp);
            return 0;
        }

        swap(a[i],a[maxp]);
        swap(a[i],a[minp]);
        a[0] = minn+1;
        if(minn<a[i-1]&&minn <a[i+1]&&minn!=a[minp]){
            printf("%d %d\n",i,minp);
            return 0;
        }
        swap(a[i],a[minp]);
    }
    printf("-1\n");
}


#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
int a[100100];

int main(){
    scanf("%d",&n);
    int maxn = 0,minn = 0,maxp = 1,minp = 1;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]);
    if(n <= 2) {
        printf("-1\n");
        return 0;
    }
    if(n==3){
        if(a[1]==a[3]) printf("-1\n");
    }
    int la=-1,lb=-1,ra=-1,rb=-1;
    int mid = (n+1)/2;
    for(int i = 1; i < mid; i++){
        if(a[i] < a[mid]){
            la = i;
        }
        if(a[i] > a[mid]){
            lb = i;
        }
    }
    for(int i = mid+1; i <= n; i++){
        if(a[i] < a[mid]){
            ra = i;
        }
        if(a[i] > a[mid]){
            rb = i;
        }
    }
   //printf("%d %d %d %d\n",la,lb,ra,rb);
    if(la!=-1&&ra!=-1&&lb!=-1){
        printf("%d %d\n",lb,mid);
        return 0;
    }
    if(la!=-1&&ra!=-1&&rb!=-1){
        printf("%d %d\n",rb,mid);
        return 0;
    }
    if(lb!=-1&&rb!=-1&&la!=-1){
        printf("%d %d\n",la,mid);
        return 0;
    }
    if(lb!=-1&&rb!=-1&&ra!=-1){
        printf("%d %d\n",ra,mid);
        return 0;
    }
    if(la!=-1&&rb!=-1){
        printf("%d %d\n",la,rb);
        return 0;
    }
    if(lb!=-1&&ra!=-1){
        printf("%d %d\n",lb,ra);
        return 0;
    }
    printf("-1\n");
}


#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int g[100010];
int n;

int solve(){
    int f1 = 0,f2 = 0;
    for(int i = 1; i< n; i++){
        if(g[i] < g[i+1]) f1 = 1;
        if(g[i] > g[i+1]) f2 = 1;
    }
    if(f1 && f2) return 1;
    return 0;
}

int main(){
    scanf("%d",&n);
    for(int i = 1; i <= n; i++)
        scanf("%d",&g[i]);
    if(n <= 2){
        printf("-1\n");
        return 0;
    }
    /*int t = g[1],flag = 0;
    for(int i = 2; i <= n; i++)
        if(t!=g[i]) flag = 1;
    if(!flag){
        printf("-1\n");
        return 0;
    }*/
    for(int i = 1; i <= n; i++)
        for(int j = i+1; j <= n; j++){
            if(g[i]==g[j]) continue;
            swap(g[i],g[j]);
            if(solve()) {
                printf("%d %d\n",i,j);
                return 0;
            }
            swap(g[i],g[j]);
        }
    printf("-1\n");
}


#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int g[100010];
int n;

int solve(){
    int f1 = 0,f2 = 0;
    for(int i = 1; i< n; i++){
        if(g[i] < g[i+1]) f1 = 1;
        if(g[i] > g[i+1]) f2 = 1;
    }
    if(f1 && f2) return 1;
    return 0;
}

int main(){
    scanf("%d",&n);
    for(int i = 1; i <= n; i++)
        scanf("%d",&g[i]);
    if(n <= 2){
        printf("-1\n");
        return 0;
    }
    int t = g[1],flag = 0;
    for(int i = 2; i <= n; i++)
        if(t!=g[i]) flag = 1;
    if(!flag){
        printf("-1\n");
        return 0;
    }
    for(int i = 1; i <= n; i++)
        for(int j = i+1; j <= n; j++){
            if(g[i]==g[j]) continue;
            swap(g[i],g[j]);
            if(solve()) {
                printf("%d %d\n",i,j);
                return 0;
            }
            swap(g[i],g[j]);
        }
    printf("-1\n");
}


#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
int a[100100];
int main(){
    scanf("%d",&n);
    int maxn = 0,minn = 0,maxp = 1,minp = 1;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]);
    if(n <= 2) {
        printf("-1\n");
        return 0;
    }
    maxn = a[1];
    minn = a[1];
    for(int i = 2; i <= n; i++){
        if(maxn < a[i]){
            maxn = a[i];
            maxp = i;
        }
        if(minn > a[i]){
            minn = a[i];
            minp = i;
        }
    }

    //printf("%d %d\n",minp,maxp);
    for(int i = 2; i < n; i++){

        swap(a[i],a[maxp]);
        if(maxn>a[i-1]&&maxn >a[i+1]&&maxn!=a[maxp]){
            printf("%d %d\n",i,maxp);
            return 0;
        }
        swap(a[i],a[maxp]);
        swap(a[i],a[minp]);
        if(minn<a[i-1]&&minn <a[i+1]&&minn!=a[minp]){
            printf("%d %d\n",i,minp);
            return 0;
        }
        swap(a[i],a[minp]);
    }
    printf("-1\n");
}


#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
int a[100100];

int solve(){
    int flag1 = 0,flag2 = 0;
    for(int i = 1; i < n; i++){
        if(a[i]<a[i+1]) flag1 = 1;
        if(a[i]>a[i+1]) flag2 = 1;
    }
    if(flag1&&flag2) return 0;
    return 1;
}

int main(){
    scanf("%d",&n);
    int maxn = 0,minn = 0,maxp = 1,minp = 1;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]);
    if(n <= 2) {
        printf("-1\n");
        return 0;
    }
    maxn = a[1];
    minn = a[1];
    for(int i = 2; i <= n; i++){
        if(maxn < a[i]){
            maxn = a[i];
            maxp = i;
        }
        if(minn > a[i]){
            minn = a[i];
            minp = i;
        }
    }
    if(n < 100){
        for(int i = 1; i <= n; i++)
            for(int j = i+1; j <= n; j++)
                if(a[i]!=a[j]){
                    swap(a[i],a[j]);
                    if(solve()){
                        printf("%d %d\n",i,j);
                    }
                    swap(a[i],a[j]);
                }
    }
    //printf("%d %d\n",minp,maxp);
    for(int i = 2; i < n; i++){
        swap(a[i],a[maxp]);
        a[0] = maxn-1;
        if(maxn>a[i-1]&&maxn >a[i+1]&&maxn!=a[maxp]){
            printf("%d %d\n",i,maxp);
            return 0;
        }

        swap(a[i],a[maxp]);
        swap(a[i],a[minp]);
        a[0] = minn+1;
        if(minn<a[i-1]&&minn <a[i+1]&&minn!=a[minp]){
            printf("%d %d\n",i,minp);
            return 0;
        }
        swap(a[i],a[minp]);
    }
    printf("-1\n");
}


#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
int a[100100];

int solve(){
    int flag1 = 0,flag2 = 0;
    for(int i = 1; i < n; i++){
        if(a[i]<a[i+1]) flag1 = 1;
        if(a[i]>a[i+1]) flag2 = 1;
    }
    if(flag1&&flag2) return 0;
    return 1;
}

int main(){
    scanf("%d",&n);
    int maxn = 0,minn = 0,maxp = 1,minp = 1;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]);
    if(n <= 2) {
        printf("-1\n");
        return 0;
    }
    maxn = a[1];
    minn = a[1];
    for(int i = 2; i <= n; i++){
        if(maxn < a[i]){
            maxn = a[i];
            maxp = i;
        }
        if(minn > a[i]){
            minn = a[i];
            minp = i;
        }
    }
    for(int i = 2; i < n; i++){
        swap(a[i],a[maxp]);
        if(maxn>a[i-1]&&maxn >a[i+1]&&maxn!=a[maxp]){
            printf("%d %d\n",i,maxp);
            return 0;
        }

        swap(a[i],a[maxp]);
        swap(a[i],a[minp]);
        if(minn<a[i-1]&&minn <a[i+1]&&minn!=a[minp]){
            printf("%d %d\n",i,minp);
            return 0;
        }
        swap(a[i],a[minp]);
    }
    printf("-1\n");
}


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

int g[100100];
//int tmp[100100];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&g[i]);
      //  tmp[i]=g[i];
    }
    if(n==1||n==2){
        printf("-1");
        return 0;
    }
   // sort(tmp,tmp+n);
    int cnt=1;
    int t=g[0];
    for(int i=1;i<n;i++){
        if(t==g[i]) continue;
        t=g[i];
        cnt++;
    }
    if(cnt==1)
    {
        printf("-1");
        return 0;
    }
    int flag=0;
    int ki,kj;
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
        {
            if(flag==1)
                break;
            if(g[j]==g[i]) continue;
            swap(g[i],g[j]);
            int sign=0;
            for(int k=0;k<n-1;k++)
            {
                if(g[k+1]>g[k]) {
                    sign=1;
                    break;
                }
            }
            int sign1=0;
            for(int k=0;k<n-1;k++)
            {
                if(g[k+1]<g[k])
                { sign1=1;
                    break;
                }
            }
            if(sign==1&&sign1==1)
            {
                flag=1;
                ki=i; kj=j;
                break;
            }
            swap(g[i],g[j]);
        }
        if(flag==0)
            printf("-1");
        else
            printf("%d %d",ki+1,kj+1);
        return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
int a[100100];
int main(){
    scanf("%d",&n);
    int maxn = 0,minn = 0,maxp = 1,minp = 1;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]);
    if(n <= 2) {
        printf("-1\n");
        return 0;
    }
    maxn = a[1];
    minn = a[1];
    for(int i = 2; i <= n; i++){
        if(maxn < a[i]){
            maxn = a[i];
            maxp = i;
        }
        if(minn > a[i]){
            minn = a[i];
            minp = i;
        }
    }

    //printf("%d %d\n",minp,maxp);
    for(int i = 1; i < n; i++){
        swap(a[i],a[maxp]);
        a[0] = maxn-1;
        if(maxn>a[i-1]&&maxn >a[i+1]&&maxn!=a[maxp]){
            printf("%d %d\n",i,maxp);
            return 0;
        }

        swap(a[i],a[maxp]);
        swap(a[i],a[minp]);
        a[0] = minn+1;
        if(minn<a[i-1]&&minn <a[i+1]&&minn!=a[minp]){
            printf("%d %d\n",i,minp);
            return 0;
        }
        swap(a[i],a[minp]);
    }
    printf("-1\n");
}


#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
int a[100100];
int main(){
    scanf("%d",&n);
    int maxn = 0,minn = 0,maxp = 1,minp = 1;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]);
    if(n <= 2) {
        printf("-1\n");
        return 0;
    }
    maxn = a[1];
    minn = a[1];
    for(int i = 2; i <= n; i++){
        if(maxn < a[i]){
            maxn = a[i];
            maxp = i;
        }
        if(minn > a[i]){
            minn = a[i];
            minp = i;
        }
    }
    for(int i = 1; i < n; i++){
        if(maxn>a[i]&&maxn >a[i+1]&&maxn!=a[i+1]){
            printf("%d %d\n",i+1,maxp);
            return 0;
        }
        if(minn<a[i]&&minn <a[i+1]&&minn!=a[i+1]){
            printf("%d %d\n",i+1,minp);
            return 0;
        }
    }
    printf("-1\n");
}


#include <cstdio>

#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int main()
{
    vector<int> vec;
    vector<int> nodups;
    set<int> sorted;

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        vec.push_back(x);
        nodups.push_back(x);
        sorted.insert(x);
    }

    if (sorted.size() <= 2) {
        printf("-1\n");
    } else {
        sort(nodups.begin(), nodups.end());
        int i, j;
        for (i = 0; i < n; ++i)
            if (vec[i] == nodups[i])
                break;
        if (i == n) i = 0;
        for (j = n - 1; j >= 0; --j)
            if (vec[j] != nodups[j])
                break;
        if (j == -1) j = n - 1;
        printf("%d %d\n", i + 1, j + 1);
    }

    return 0;
}


#include <cstdio>

#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int main()
{
    vector<int> vec;
    vector<int> nodups;
    set<int> sorted;

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        vec.push_back(x);
        nodups.push_back(x);
        sorted.insert(x);
    }

    if (sorted.size() <= 2) {
        printf("-1\n");
    } else {
        sort(nodups.begin(), nodups.end());
        int med = nodups[n / 2];
        int i;
        for (i = 0; i < n; ++i)
            if (nodups[i] == med)
                break;
        if (i == 0) printf("%d %d\n", 1, n);
        else printf("%d %d\n", 1, i + 1);
    }

    return 0;
}


#include <cstdio>

#include <algorithm>
#include <iterator>
#include <set>
#include <vector>

using namespace std;

int main()
{
    vector<int> vec;
    set<int> sorted;

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        vec.push_back(x);
        sorted.insert(x);
    }

    if (sorted.size() == 1 || vec.size() == 2) {
        printf("-1\n");
    } else {
        vector<int> nodups;
        copy(sorted.begin(), sorted.end(), back_inserter(nodups));
        int med = nodups[n / 2];
        int i;
        for (i = 0; i < n; ++i)
            if (nodups[i] == med)
                break;
        if (i == 0) printf("%d %d\n", 1, n);
        else printf("%d %d\n", 1, i + 1);
    }

    return 0;
}


#include <cstdio>

#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int main()
{
    vector<int> vec;
    vector<int> nodups;
    set<int> sorted;

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        vec.push_back(x);
        nodups.push_back(x);
        sorted.insert(x);
    }

    if (sorted.size() <= 2) {
        printf("-1\n");
    } else {
        sort(nodups.begin(), nodups.end());
        for (int i = 0; i < n; ++i)
            if (nodups[i] == vec[i]) {
                while (i < n && nodups[i] == vec[i]) i++;
                if (i < n)
                    printf("%d %d\n", i + 1, ((i + 1) % n + 1));
                else printf("%d %d\n", 1, n - 1);
            }
    }

    return 0;
}


#include <cstdio>

#include <algorithm>
#include <iterator>
#include <vector>

using namespace std;

const int MAXN = 100002;

int main()
{
    int vec[MAXN];
    int sort1[MAXN];
    int sort2[MAXN];

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &vec[i]);
        sort1[i] = sort2[i] = vec[i];
    }

    if (n <= 2) {
        printf("-1\n");
        return 0;
    }

    sort(sort1, sort1 + n);
    sort(sort2, sort2 + n, greater<int>());
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            if (vec[i] != vec[j] && (vec[i] != sort1[j] || vec[j] != sort1[i])  && (vec[i] != sort2[j] || vec[j] != sort2[i])) {
                printf("%d %d\n", i + 1, j + 1);
                return 0;
            }

    printf("-1\n");
    return 0;
}


#include <cstdio>

#include <algorithm>
#include <iterator>
#include <set>
#include <vector>

using namespace std;

int main()
{
    vector<int> vec;
    vector<int> sort1;
    vector<int> sort2;
    set<int> sorted;

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        vec.push_back(x);
        sort1.push_back(x);
        sort2.push_back(x);
        sorted.insert(x);
    }

    if (sorted.size() == 1 || vec.size() <= 2) {
        printf("-1\n");
        return 0;
    }

    sort(sort1.begin(), sort1.end());
    sort(sort2.begin(), sort2.end(), greater<int>());
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            if (vec[i] != vec[j] && (vec[i] != sort1[j] || vec[j] != sort1[i])  && (vec[i] != sort2[j] || vec[j] != sort2[i])) {
                printf("%d %d\n", i + 1, j + 1);
                return 0;
            }

    printf("-1\n");
    return 0;
}


#include <cstdio>

#include <algorithm>
#include <iterator>
#include <set>
#include <vector>

using namespace std;

int main()
{
    vector<int> vec;
    set<int> sorted;

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        vec.push_back(x);
        sorted.insert(x);
    }

    if (sorted.size() == 1 || vec.size() == 2) {
        printf("-1\n");
    } else {
        vector<int> nodups;
        copy(sorted.begin(), sorted.end(), back_inserter(nodups));
        int med = nodups[nodups.size() / 2];
        int i;
        for (i = 0; i < n; ++i)
            if (vec[i] == med)
                break;
        if (i == 0) printf("%d %d\n", 1, n);
        else printf("%d %d\n", 1, i + 1);
    }

    return 0;
}


#include <cstdio>

#include <algorithm>
#include <iterator>
#include <set>
#include <vector>

using namespace std;

int main()
{
    vector<int> vec;
    set<int> sorted;

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        vec.push_back(x);
        sorted.insert(x);
    }

    if (sorted.size() == 1 || vec.size() == 2) {
        printf("-1\n");
    } else {
        vector<int> nodups;
        copy(sorted.begin(), sorted.end(), back_inserter(nodups));
        int med = nodups[nodups.size() / 2];
        int i;
        for (i = 0; i < n; ++i)
            if (vec[i] == med)
                break;
        if (i == 0) printf("%d %d\n", 2, n);
        else printf("%d %d\n", 1, i + 1);
    }

    return 0;
}


#include <cstdio>

#include <algorithm>
#include <iterator>
#include <vector>

using namespace std;

const int MAXN = 100002;

int main()
{
    int vec[MAXN];
    int sort1[MAXN];
    int sort2[MAXN];

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &vec[i]);
        sort1[i] = sort2[i] = vec[i];
    }

    if (n <= 2) {
        printf("-1\n");
        return 0;
    }

    sort(sort1, sort1 + n);
    sort(sort2, sort2 + n, greater<int>());
    for (int i = 1; i < n; ++i)
        if (!((vec[i] == sort1[i - 1] && vec[i - 1] == sort1[i]) || (vec[i] == sort2[i - 1] && vec[i - 1] == sort2[i]) || (vec[i] == vec[i - 1]))) {
            printf("%d %d", i, i + 1);
            return 0;
        }

    printf("-1\n");
    return 0;
}


#include <cstdio>

#include <algorithm>
#include <iterator>
#include <set>
#include <vector>

using namespace std;

int main()
{
    vector<int> vec;
    vector<int> sort1;
    vector<int> sort2;

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        vec.push_back(x);
        sort1.push_back(x);
        sort2.push_back(x);
    }

    if (vec.size() <= 2) {
        printf("-1\n");
        return 0;
    }

    sort(sort1.begin(), sort1.end());
    sort(sort2.begin(), sort2.end(), greater<int>());
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            if (vec[i] != vec[j] && (vec[i] != sort1[j] || vec[j] != sort1[i])  && (vec[i] != sort2[j] || vec[j] != sort2[i])) {
                printf("%d %d\n", i + 1, j + 1);
                return 0;
            }

    printf("-1\n");
    return 0;
}


#include <cstdio>

#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int main()
{
    vector<int> vec;
    vector<int> nodups;
    set<int> sorted;

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        vec.push_back(x);
        nodups.push_back(x);
        sorted.insert(x);
    }

    if (sorted.size() <= 2) {
        printf("-1\n");
    } else {
        sort(nodups.begin(), nodups.end());
        for (int i = 0; i < n; ++i)
            if (nodups[i] == vec[i]) {
                int j = i + 1;
                while (j < n && vec[j] == vec[i]) j++;
                if (j == n) {
                    j = 0;
                    while (j < n && vec[j] == vec[i]) j++;
                }
                printf("%d %d\n", i + 1, j + 1);
                break;
            }
    }

    return 0;
}


#include <iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#define  maxn 20011
using namespace std;
int main()
{
  int i,j,n;
  int a[10001];
  while(scanf("%d",&n)!=EOF)
  {
       int count=1;
        for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
         if(i>1)
            {
                 if(a[i-1]==a[i])
                    count++;
            }

        }
     if(n==1||n==2||count==n)
          {
               printf("-1\n");
               continue;
          }
         else
           {
                 int num1,num2;
                 int num=a[1];
                 for(i=2;i<=n;i++)
                 {
                       if(a[i]!=num)
                         {
                              num1=num;
                              num2=a[i];
                              break;
                         }
                       else if(a[i]==num)
                             num=a[i];
                 }
                 printf("%d %d\n",num1,num2);
           }
  }
return 0;
}