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

using namespace std;
 vector <int> a;

int main () {
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);

	int n,sum=1,raod=1;
	cin>>n;

	a.push_back(-49856);
	string s;

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

	getline(cin,s);
	for (int i=1; i<=n; i++){
		getline(cin,s);
		a.push_back(((s[1]-'0')*10+s[2]-'0')*60+(s[4]-'0')*10+s[5]-'0');
		if (s.substr(7,4)=="p.m.") a[i]+=720;

		if (a[i]==a[i-1]) raod++; else raod=1;

		if (a[i]<a[i-1]) sum++; else
			if (raod==11) {
				sum++;
				raod=1;
			};
	};

	cout<<sum;

 return 0;
}


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

using namespace std;
 vector <int> a;

int main () {
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);

	int n,sum=1,raod=1;
	cin>>n;

	a.push_back(-49856);
	string s;

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

	getline(cin,s);
	for (int i=1; i<=n; i++){
		getline(cin,s);
		int h=(s[1]-'0')*10+s[2]-'0',m=(s[4]-'0')*10+s[5]-'0';
		if (h==12 && s[7]=='a') h=0;
		if (h<12 && s[7]=='p') h+=12;
		a.push_back(h*60+m);;

		if (a[i]==a[i-1]) raod++; else raod=1;
		if (a[i]<a[i-1]) sum++; else
			if (raod==11) {
				sum++;
				raod=1;
			};
	};

	cout<<sum;

 return 0;
}


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

using namespace std;
 vector <int> a;

int main () {
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);

	int n,sum=1,raod=1;
	cin>>n;

	a.push_back(-49856);
	string s;

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

	getline(cin,s);
	for (int i=1; i<=n; i++){
		getline(cin,s);
		a.push_back(((s[1]-'0')*10+s[2]-'0')*60+(s[4]-'0')*10+s[5]-'0');
		if (s.substr(7,4)=="p.m."){
			if (a[i]==720) a[i]=0; else a[i]+=720;
		} else if (a[i]==720) a[i]=0;

		if (a[i]==a[i-1]) raod++; else raod=1;

		if (a[i]<a[i-1]) sum++; else
			if (raod==11) {
				sum++;
				raod=1;
			};
	};

	cout<<sum;

 return 0;
}


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

using namespace std;
 vector <int> a;

int main () {
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	int sum=1,n,r=1;
	string s;

	a.push_back(-13784);
	cin>>n;
	getline(cin,s);

	for (int i=1; i<=n; i++){
		getline(cin,s);
		int h,m;
		h=(s[1]-'0')*10+s[2]-'0';
		m=(s[4]-'0')*10+s[5]-'0';
		if (h==12 && s[7]=='m') h=0;
		if (h<12 && s[7]=='p') h+=12;
		a.push_back(h*60+m);
		if (a[i]==a[i-1]) r++; else r=1;
		if (a[i]<a[i-1]) sum++; else
			if (r==11){
				sum++;
				r=1;
			};
	};

	cout<<sum;

 return 0;
}


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

using namespace std;
 vector <int> a;

int main () {
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);

	int n,sum=1,raod=1;
	cin>>n;

	a.push_back(-49856);
	string s;

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

	getline(cin,s);
	for (int i=1; i<=n; i++){
		getline(cin,s);
		a.push_back(((s[1]-'0')*10+s[2]-'0')*60+(s[4]-'0')*10+s[5]-'0');
		if (s.substr(7,4)=="p.m.")
			if (a[i]==720) a[i]=0; else a[i]+=720;

		if (a[i]==a[i-1]) raod++; else raod=1;

		if (a[i]<a[i-1]) sum++; else
			if (raod==11) {
				sum++;
				raod=1;
			};
	};

	cout<<sum;

 return 0;
}


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

using namespace std;
 vector <int> a;

int main () {
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);

	int n,sum=1,raod=1;
	cin>>n;

	a.push_back(-49856);
	string s;

	getline(cin,s);
	for (int i=1; i<=n; i++){
		getline(cin,s);
		a.push_back(((s[1]-'0')*10+s[2]-'0')*60+(s[4]-'0')*10+s[5]-'0');
		if (s.substr(7,4)=="p.m.") a[i]+=720;
		if (a[i]==a[i-1]) raod++; else raod=1;
		if (a[i]<a[i-1]) sum++; else
			if (raod==11) {
				sum++;
				raod=1;
			};
	};

	cout<<sum;

 return 0;
}


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

using namespace std;
 vector <int> a;

int main () {
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);

	int n,sum=1,raod=1;
	cin>>n;

	a.push_back(0);
	string s;

	getline(cin,s);
	for (int i=1; i<=n; i++){
		getline(cin,s);
		a.push_back(((s[1]-'0')*10+s[2]-'0')*60+(s[4]-'0')*10+s[5]-'0');
		if (s.substr(7,4)=="p.m.") a[i]+=720;
		if (a[i]==a[i-1]) raod++; else raod=1;
		if (a[i]<a[i-1]) sum++; else
			if (raod==11) {
				sum++;
				raod=1;
			};
	};

	cout<<sum;

 return 0;
}


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

using namespace std;
 vector <int> a;

int main () {
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	int sum=1,n,r=1;
	string s;s

	a.push_back(-13784);
	cin>>n;
	getline(cin,s);

	for (int i=1; i<=n; i++){
		getline(cin,s);
		int h,m;
		h=(s[1]-'0')*10+s[2]-'0';
		m=(s[4]-'0')*10+s[5]-'0';
		if (h==12 && s[7]=='m') h=0;
		if (h<12 && s[7]=='p') h+=12;
		a.push_back(h*60+m);
		if (a[i]==a[i-1]) r++; else r=1;
		if (a[i]<a[i-1]) sum++; else
			if (r==11){
				sum++;
				r=1;
			};
	};

	cout<<sum;

 return 0;
}


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

char a[105][105];

int hh[105], mm [105];

int time (int h, int m){

    int time = h * 100 + m;

    return time;
}

int main (){

    int n; cin >> n;

    scanf("\n");
    int days = 0;

    for(int i = 0; i < n; ++ i){
        cin.getline (a[i], 105);
        int h1 = (a[i][1] - '0') * 10;
        int h2 = (a[i][2] - '0');
        hh[i] = h1 + h2;
        int m1 = (a[i][4] - '0') * 10;
        int m2 = a[i][5] - '0';
        mm[i] = m1 + m2;
        if(a[i][7] == 'p'){
            hh[i] += 12;
        }
    }

    for(int i = 0; i < n; ++ i){
        ++ days;
        for(int j = i; (time (hh[j], mm[j]) <= time(hh[j + 1], mm[j + 1])) && (j < n - 1); ++ j, i += j){

            int task = 0;

            for(int k = j + 1; (time (hh[k], mm[k]) == time(hh[k + 1], mm[k + 1])) && (k < n - 1); ++ k, ++ task);

            days += task / 10;

            j += task;
        }
    }

    cout << days;

    return 0;
}


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

char a[105][105];

int hh[105], mm [105];

int time (int h, int m){

    int time = h * 100 + m;

    return time;
}

int main (){

    int n; cin >> n;

    scanf("\n");
    int days = 0;

    for(int i = 0; i < n; ++ i){
        cin.getline (a[i], 105);
        int h1 = (a[i][1] - '0') * 10;
        int h2 = (a[i][2] - '0');
        hh[i] = h1 + h2;
        int m1 = (a[i][4] - '0') * 10;
        int m2 = a[i][5] - '0';
        mm[i] = m1 + m2;
        if(a[i][7] == 'p' && hh[i] != 12){
            hh[i] += 12;
        } else if(hh[i] == 12) hh[i] = 0;
    }

    for(int i = 0; i < n; ){
        ++ days;
        int j;
        for( j = i; (time (hh[j], mm[j]) <= time(hh[j + 1], mm[j + 1])) && (j < n - 1); ++ j){

            int task = 0;

            for(int k = j + 1; (time (hh[k], mm[k]) == time(hh[k + 1], mm[k + 1])) && (k < n - 1); ++ k, ++ task);

            days += task / 10;

            j += task;
        }
        i = j + 1;
    }

    cout << days;

    return 0;
}


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

char a[105];

int hh, mm;
int x[105];

int time (int h, int m){

    int time = h * 100 + m;

    return time;
}

int main (){

    int n; cin >> n;

    scanf("\n");
    int days = 0;

    for(int i = 0; i < n; ++ i){
        cin.getline (a, 105);
        int h1 = (a[1] - '0') * 10;
        int h2 = (a[2] - '0');
        hh = h1 + h2;
        int m1 = (a[4] - '0') * 10;
        int m2 = a[5] - '0';
        mm = m1 + m2;
        if(a[7] == 'p' && hh != 12){ // 12 am == 0 &&  12 pm == 12
            hh += 12;
        } else if(a[7] == 'a'&& hh == 12) hh = 0;

        x[i] = time(hh, mm);
    }

    for(int i = 0; i < n; ++ i, ++ days){
        int j;
        for(j = i; (x[j] <= x[j + 1]) && (j < n - 1); ){
            if(x[j] == x[j + 1]){
                int task = 1;
                int k;
                for(k = j + 1; (x[k] == x[k + 1]) && (k < n - 1); ++ k){
                    ++ task;
                }
                days += task / 10;
                j = k;
            } else {
                ++ j;
            }
        }
        i = j;
    }

    cout << days;

    return 0;
}


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

char a[105];

int hh, mm;
int x[105];

int time (int h, int m){

    int time = h * 100 + m;

    return time;
}

int main (){

    int n; cin >> n;

    scanf("\n");
    int days = 0;

    for(int i = 0; i < n; ++ i){
        cin.getline (a, 105);
        int h1 = (a[1] - '0') * 10;
        int h2 = (a[2] - '0');
        hh = h1 + h2;
        int m1 = (a[4] - '0') * 10;
        int m2 = a[5] - '0';
        mm = m1 + m2;
        if(a[7] == 'p' && hh != 12){
            hh += 12;
        } else if(hh == 12) hh = 0;

        x[i] = time(hh, mm);
    }

    for(int i = 0; i < n; ++ i, ++ days){
        int j;
        for(j = i; (x[j] <= x[j + 1]) && (j < n - 1); ){
            if(x[j] == x[j + 1]){
                int task = 1;
                int k;
                for(k = j + 1; (x[k] == x[k + 1]) && (k < n - 1); ++ k){
                    ++ task;
                }
                days += task / 10;
                j = k;
            } else {
                ++ j;
            }
        }
        i = j;
    }

    cout << days;

    return 0;
}


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

char a[105];

int hh, mm;
int x[105];

int time (int h, int m){

    int time = h * 100 + m;

    return time;
}

int main (){

    int n; cin >> n;

    scanf("\n");
    int days = 0;

    for(int i = 0; i < n; ++ i){
        cin.getline (a, 105);
        int h1 = (a[1] - '0') * 10;
        int h2 = (a[2] - '0');
        hh = h1 + h2;
        int m1 = (a[4] - '0') * 10;
        int m2 = a[5] - '0';
        mm = m1 + m2;
        if(a[7] == 'p' && hh != 12){
            hh += 12;
        } else if(hh == 12) hh = 0;

        x[i] = time(hh, mm);
    }

    for(int i = 0; i < n; ++ i, ++ days){
        int j;
        for(j = i; (x[j] <= x[j + 1]) && (j < n - 1); ){
            if(x[j] == x[j + 1]){
                int task = 0;
                int k;
                for(k = j + 1; (x[k] == x[k + 1]) && (k < n - 1); ++ k){
                    ++ task;
                }
                days += task / 10;
                j = k;
            } else {
                ++ j;
            }
        }
        i = j;
    }

    cout << days;

    return 0;
}


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

char a[105];

int hh, mm;
int x[105];

int time (int h, int m){

    int time = h * 100 + m;

    return time;
}

int main (){

    int n; cin >> n;

    scanf("\n");
    int days = 0;

    for(int i = 0; i < n; ++ i){
        cin.getline (a, 105);
        int h1 = (a[1] - '0') * 10;
        int h2 = (a[2] - '0');
        hh = h1 + h2;
        int m1 = (a[4] - '0') * 10;
        int m2 = a[5] - '0';
        mm = m1 + m2;
        if(a[7] == 'p' && hh != 12){ // 12 am == 0 &&  12 pm == 12
            hh += 12;
        } else if(a[7] == 'a' hh == 12) hh = 0;

        x[i] = time(hh, mm);
    }

    for(int i = 0; i < n; ++ i, ++ days){
        int j;
        for(j = i; (x[j] <= x[j + 1]) && (j < n - 1); ){
            if(x[j] == x[j + 1]){
                int task = 1;
                int k;
                for(k = j + 1; (x[k] == x[k + 1]) && (k < n - 1); ++ k){
                    ++ task;
                }
                days += task / 10;
                j = k;
            } else {
                ++ j;
            }
        }
        i = j;
    }

    cout << days;

    return 0;
}


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

char a[105][105];

int hh[105], mm [105];

int time (int h, int m){

    int time = h * 100 + m;

    return time;
}

int main (){

    int n; cin >> n;

    scanf("\n");
    int days = 0;

    for(int i = 0; i < n; ++ i){
        cin.getline (a[i], 105);
        int h1 = (a[i][1] - '0') * 10;
        int h2 = (a[i][2] - '0');
        hh[i] = h1 + h2;
        int m1 = (a[i][4] - '0') * 10;
        int m2 = a[i][5] - '0';
        mm[i] = m1 + m2;
        if(a[i][7] == 'p'){
            hh[i] += 12;
        }
    }

    for(int i = 0; i < n; ++ i){
        ++ days;
        for(int j = i; time (hh[j], mm[j]) <= time(hh[j + 1], mm[j + 1]); ++ j, ++ i){
            int task = 0;
            for(int k = j + 1; time (hh[k], mm[k]) == time(hh[k + 1], mm[k + 1]); ++ k, ++ task);
            days += task / 10;
            j += task;
        }
    }

    cout << days;

    return 0;
}


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

char a[105][105];

int hh[105], mm [105];

int time (int h, int m){

    int time = h * 100 + m;

    return time;
}

int main (){

    int n; cin >> n;

    scanf("\n");
    int days = 0;

    for(int i = 0; i < n; ++ i){
        cin.getline (a[i], 105);
        int h1 = (a[i][1] - '0') * 10;
        int h2 = (a[i][2] - '0');
        hh[i] = h1 + h2;
        int m1 = (a[i][4] - '0') * 10;
        int m2 = a[i][5] - '0';
        mm[i] = m1 + m2;
        if(a[i][7] == 'p'){
            hh[i] += 12;
        } else if(hh[i] == 12) hh[i] = 0;
    }

    for(int i = 0; i < n; ){
        ++ days;
        int j;
        for( j = i; (time (hh[j], mm[j]) <= time(hh[j + 1], mm[j + 1])) && (j < n - 1); ++ j){

            int task = 0;

            for(int k = j + 1; (time (hh[k], mm[k]) == time(hh[k + 1], mm[k + 1])) && (k < n - 1); ++ k, ++ task);

            days += task / 10;

            j += task;
        }
        i = j + 1;
    }

    cout << days;

    return 0;
}


#include<iostream>
using namespace std;
int ntim,tim,cnt;
int gettime(string s)
{
	int hours=((s[1]-'0')*10+s[2]-'0');
	int mins=((s[4]-'0')*10+s[5]-'0');
	return hours+mins+(s[7]=='p'?720:0);
}
int main()
{
	int n,days=1;
	cin>>n;
	cin.ignore();
	string s;
	while(n--)
	{
		getline(cin,s);
		int ntim=gettime(s);
		if(ntim!=tim)
			cnt=1;
		if(ntim<tim)
			days++;
		if(ntim==tim)
			if(++cnt>10)
			{
				days++;
				cnt=1;
			}
		tim=ntim;
	}
	cout<<days;
}


#include<iostream>
using namespace std;
bool cmp(string a,string b)
{
	if(a.substr(7,1)>b.substr(7,1))
		return true;
	else if(a.substr(7,1)==b.substr(7,1))
		if(a.substr(1,5)>b.substr(1,5))
			return true;
	return false;
}
int main()
{
	int n,js=1;
	cin>>n;
	cin.ignore();
	string s[n];
	getline(cin,s[0]);
	for(int i=1;i<n;i++)
	{
		getline(cin,s[i]);
		if(s[i].substr(1,2)=="12")
		{
			s[i][2]='0';
			s[i][1]='0';
		}
		if(i>9)
		{
			int f=1;
			for(int j=i-10;j<i;j++)
				if(s[i].substr(0,12)!=s[j].substr(0,12))
					f=0;// 10 [00:00 a.m.]: x
			if(f)
			{
				js++;
				s[i-1][0]='a';
				continue;
			}
		}
		if(cmp(s[i-1],s[i]))
			js++;
	}
	cout<<js;
}


#include<iostream>
using namespace std;
bool cmp(string a,string b)
{
	if(a.substr(7,1)<b.substr(7,1))
		return true;
	else if(a.substr(7,1)==b.substr(7,1))
		if(a.substr(1,5)<b.substr(1,5))
			return true;
	return false;
}
int main()
{
	int n,js=1;
	cin>>n;
	cin.ignore();
	string s[n];
	getline(cin,s[0]);
	for(int i=1;i<n;i++)
	{
		getline(cin,s[i]);
		if(i>9)
		{
			int f=1;
			for(int j=i-10;j<i;j++)
				if(s[i].substr(0,13)!=s[j].substr(0,13))
					f=0;// 10 [00:00 a.m.]: x
			if(f)
			{
				js++;
				s[i-1][0]='#';
				continue;
			}
		}
		if(cmp(s[i],s[i-1]))
			js++;
	}
	cout<<js;
}


#include<iostream>
using namespace std;
bool cmp(string a,string b)
{
	if(a.substr(7,1)>b.substr(7,1))
		return true;
	else if(a.substr(7,1)==b.substr(7,1))
		if(a.substr(1,5)>b.substr(1,5))
			return true;
	return false;
}
int main()
{
	int n,js=1;
	cin>>n;
	cin.ignore();
	string s[n];
	getline(cin,s[0]);
	for(int i=1;i<n;i++)
	{
		getline(cin,s[i]);
		if(s[i].substr(1,2)=="12")
		{
			s[i][2]='0';
			s[i][1]='0';
			if(s[i][7]=='p')
				s[i][7]='a';
			else
				s[i][7]='p';
		}
		if(i>9)
		{
			int f=1;
			for(int j=i-10;j<i;j++)
				if(s[i].substr(0,12)!=s[j].substr(0,12))
					f=0;// 10 [00:00 a.m.]: x
			if(f)
			{
				js++;
				s[i-1][0]='a';
				continue;
			}
		}
		if(cmp(s[i-1],s[i]))
			js++;
	}
	cout<<js;
}


#include<bits/stdc++.h>
using namespace std;
int readtime(){
	string s;
	getline(cin,s);
	int h,m;
	char c;
	sscanf(s.data(),"[%d:%d %c.m]",&h,&m,&c);
	if(h==12)
		h=0;
	int time=h*60+m;
	if(c=='p')
		time+=12*60;
	return time;
}
int a[100];
int main()
{
	int n;
	cin>>n;
	cin.ignore();
	for(int i=0;i<n;i++)
		a[i]=readtime();
	int ans=1,t=0,ptr=0;
	for(;;t++)
	{
		if(t==1440)
			ans++,
			t=0;
		for(int i=0;i<10&&ptr<n&&a[ptr]==t;i++,ptr++);
		if(!(n-ptr))
			break;
	}
	cout<<ans;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	cin.ignore();
	string s[n];
	int a[n];
	for(int i=0;i<n;i++)
	{
		getline(cin,s[i]);
		int hour=((s[i][1]-'0')*10+(s[i][2]-'0'))*60;
		int minu=(s[i][4]-'0')+s[i][5]-'0';
		a[i]=minu+hour+(s[i][7]=='p'?720:0);
	}
	int t=0,days=1,j=0,cnt=1;
	if(n==1)
	{
		cout<<1;
		return 0;
	}
	while(j<=n)
	{
		if(a[j-1]==a[j])
		{
			cnt++;
			j++;
			if(cnt>10)
				cnt-=10,
				days++;
		}
		else if(t>a[j])
			days++,
			t=a[j],
			j++,
			cnt=1;
		else
			t=a[j],
			j++,
			cnt=1;
	}
	cout<<days;
}


#include<iostream>
using namespace std;
bool cmp(string a,string b)
{
	if(a.substr(7,1)>b.substr(7,1))
		return true;
	else if(a.substr(7,1)==b.substr(7,1))
		if(a.substr(1,5)>b.substr(1,5))
			return true;
	return false;
}
int main()
{
	int n,js=1;
	cin>>n;
	cin.ignore();
	string s[n];
	getline(cin,s[0]);
	for(int i=1;i<n;i++)
	{
		getline(cin,s[i]);
		if(s[i].substr(1,2)=="12")
			if(s[i][7]=='p')
				s[i][7]='a',
				s[i][2]='0',
				s[i][1]='0';
			else
				s[i][7]='a';
				s[i][2]='0',
				s[i][1]='0';
		if(i>9)
		{
			int f=1;
			for(int j=i-10;j<i;j++)
				if(s[i].substr(0,12)!=s[j].substr(0,12))
					f=0;// 10 [00:00 a.m.]: x
			if(f)
			{
				js++;
				s[i-1][0]='a';
				continue;
			}
		}
		if(cmp(s[i-1],s[i]))
			js++;
	}
	cout<<js;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	cin.ignore();
	string s[n];
	int a[n];
	for(int i=0;i<n;i++)
	{
		getline(cin,s[i]);
		int hour=((s[i][1]-'0')*10+(s[i][2]-'0'));
		int minu=(s[i][4]-'0')*10+(s[i][5]-'0');
		a[i]=minu+hour*60+(s[i][7]=='p'?720:0);
	}
	int t=0,days=1,j=0,cnt=1;
	if(n==1)
	{
		cout<<1;
		return 0;
	}
	while(j<n)
	{
		if(a[j-1]==a[j])
		{
			cnt++;
			j++;
			if(cnt>10)
				cnt-=10,
				days++;
		}
		if(t>a[j])
			days++,
			t=a[j],
			j++,
			cnt=1;
		else if(t<a[j])
			t=a[j],
			j++,
			cnt=1;
	}
	cout<<days;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	cin.ignore();
	string s[n];
	int a[n];
	for(int i=0;i<n;i++)
	{
		getline(cin,s[i]);
		int hour=((s[i][1]-'0')*10+(s[i][2]-'0'));
		int minu=(s[i][4]-'0')*10+(s[i][5]-'0');
		if(s[i][7]=='p')
			a[i]=720;
		else
			a[i]=0;
		a[i]+=minu+hour*60;
	}
	int t=0,days=1,j=0,cnt=1;
	if(n==1)
	{
		cout<<1;
		return 0;
	}
	while(j<n)
	{
		if(a[j-1]==a[j])
		{
			cnt++;
			j++;
			if(cnt>10)
				cnt-=10,
				days++;
		}
		if(t>a[j])
			days++,
			t=a[j],
			j++,
			cnt=1;
		else if(t<a[j])
			t=a[j],
			j++,
			cnt=1;
	}
	cout<<days;
}


#include<iostream>
using namespace std;
bool cmp(string a,string b)
{
	if(a.substr(7,1)>b.substr(7,1))
		return true;
	else if(a.substr(7,1)==b.substr(7,1))
		if(a.substr(1,5)>b.substr(1,5))
			return true;
	return false;
}
int main()
{
	int n,js=1;
	cin>>n;
	cin.ignore();
	string s[n];
	getline(cin,s[0]);
	for(int i=1;i<n;i++)
	{
		getline(cin,s[i]);
		if(s[i].substr(1,2)=="12")
		{
			if(s[i][7]=='p')
				s[i][7]='a',
				s[i][2]='0',
				s[i][1]='0';
			else
				s[i][7]='a';
				s[i][2]='0',
				s[i][1]='0';
		}
		if(i>9)
		{
			int f=1;
			for(int j=i-10;j<i;j++)
				if(s[i].substr(0,12)!=s[j].substr(0,12))
					f=0;// 10 [00:00 a.m.]: x
			if(f)
			{
				js++;
				s[i-1][0]='a';
				continue;
			}
		}
		if(cmp(s[i-1],s[i]))
			js++;
	}
	cout<<js;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	cin.ignore();
	string s[n];
	int a[n];
	for(int i=0;i<n;i++)
	{
		getline(cin,s[i]);
		int hour=((s[i][1]-'0')*10+(s[i][2]-'0'));
		int minu=(s[i][4]-'0')*10+(s[i][5]-'0');
		a[i]=minu+hour*60+(s[i][7]=='p'?720:0);
		cout<<a[i]<<endl;
	}
	int t=0,days=1,j=0,cnt=1;
	if(n==1)
	{
		cout<<1;
		return 0;
	}
	while(j<n)
	{
		if(a[j-1]==a[j])
		{
			cnt++;
			j++;
			if(cnt>10)
				cnt-=10,
				days++;
		}
		if(t>a[j])
			days++,
			t=a[j],
			j++,
			cnt=1;
		else if(t<a[j])
			t=a[j],
			j++,
			cnt=1;
	}
	cout<<days;
}


#include<iostream>
using namespace std;
bool cmp(string a,string b)
{
	if(a.substr(7,1)>b.substr(7,1))
		return true;
	else if(a.substr(7,1)==b.substr(7,1))
		if(a.substr(1,5)>b.substr(1,5))
			return true;
	return false;
}
int main()
{
	int n,js=1;
	cin>>n;
	cin.ignore();
	string s[n];
	getline(cin,s[0]);
	for(int i=1;i<n;i++)
	{
		getline(cin,s[i]);
		if(s[i].substr(1,2)=="12")
		{
			s[i][2]='0';
			s[i][1]='0';
			s[i][7]='a';
		}
		if(i>9)
		{
			int f=1;
			for(int j=i-10;j<i;j++)
				if(s[i].substr(0,12)!=s[j].substr(0,12))
					f=0;// 10 [00:00 a.m.]: x
			if(f)
			{
				js++;
				s[i-1][0]='a';
				continue;
			}
		}
		if(cmp(s[i-1],s[i]))
			js++;
	}
	cout<<js;
}


#include<iostream>
using namespace std;
int ntim,tim,cnt;
int gettime(string s)
{
	int hours=((s[1]-'0')*10+(s[2]-'0'));
	int mins=((s[4]-'0')*10+(s[5]-'0'));
	return hours*60+mins+(s[7]=='p'?720:0);
}
int main()
{
	int n,days=1;
	cin>>n;
	cin.ignore();
	string s;
	while(n--)
	{
		getline(cin,s);
		int ntim=gettime(s);
		if(ntim!=tim)
			cnt=1;
		if(ntim<tim)
			days++;
		if(ntim==tim)
			if(++cnt>10)
			{
				days++;
				cnt=1;
			}
		tim=ntim;
	}
	cout<<days;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
// so your approach won't work tobi :( but it doesn't mean that it's not correct
// of course prime factorization for all number and combaring the factors should work but think in a different approach
// why? you can't get all primes to 1e9?
// hmm you 're right i think it will TLE even if we calculate until we reach 499999993
// maybe normal factorization would work?
// don't think so honestly
// can we combine them both Tobi?
// what do you mean?
// i mean that we know the fact that there will always be a divisor before sqrt(n) and one after sqrt(n) or i * i = n
// YOU ARE GEnUIS  that's mean we only need to calculate the prime until sqrt(1e9) then we try to factorize it % the prime list !!
// aha and also the fact that there will always be a valid prime factor would make you relief even more 1e6 + 33, 1e6 + 3 is the first two primes after sqrt(1e9) so it will never fail
// so we can keep recurse until we reach for two prime factors this should not TLE pretty sure
// ok but just memoize each answer or make a visited array or map just in case?
// yea sure let's implement it now
// dude you 're so dump sqrt(1e9) is 1e3 wtf man :D truly wtf :'D
// oops :D well now it's so easy problem but you almost solved for constraints 1e12 as well so you should be proud :'D

int N, a;
vector <int> primes, Numbers;
map < int, map <int, int> > mp;
map <int, bool> done;

bool is_Prime(int x)
{
    if(x < 4) return true;
    if(x % 2 == 0) return false;
    for(int i = 3; i * i <= x; i += 2)
        if(x % i == 0)
            return false;
    return true;
}
int main()
{
    for(int i = 2; i <= (int)1e3 + 5; ++i)
        if(is_Prime(i))
            primes.push_back(i);
    cin >> N;
    while(N--)
    {
        cin >> a;
        int x = a;
        if(done[a]) continue;
        Numbers.push_back(a);
        while(a != 1)
        {
            for(int i = 0; i < primes.size(); ++i)
            {
                if(a % primes[i] == 0)
                {
                    mp[x][primes[i]]++;
                    a /= primes[i];
                    break;
                }
            }
        }
        done[x] = true;
    }

    for(int i = 2; i < primes.size(); ++i)
    {
        int cur = -1;
        for(int j = 0; j < Numbers.size(); ++j)
        {
            if(cur == -1)
            {
                cur = mp[Numbers[j]][primes[i]];
                continue;
            }
            if(mp[Numbers[j]][primes[i]] != cur)
                 return cout << "NO", 0;
        }
    }
    cout << "YES";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long  lint;
const lint N = 123456;

lint lcm(lint a, lint b){
  lint temp = __gcd(a, b);
  return temp ? (a / temp * b) : 0;
}
bool check(lint y, lint z){
  if(y%z != 0) return 0;
  int x = y/z;
  while(x%2 == 0 || x%3 == 0){
    if(x%3 == 0) x/=3;
    else x/=2;
  }
  return x == 1;
}
lint arr[N];
int main(){
  lint n;
  cin>>n;
  for(lint i = 0; i < n ; i++) cin>>arr[i];
  // cout << result << '\n';
  sort(arr, arr + n);
  for(lint i = 1; i < n; i++){
    if(!check((arr[0]*6*6*6), arr[i])){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long  lint;
const lint N = 123456;

lint lcm(lint a, lint b){
  lint temp = __gcd(a, b);
  return temp ? (a / temp * b) : 0;
}
bool check(lint y, lint z){
  if(y%z != 0) return 0;
  int x = y/z;
  while(x%2 == 0 || x%3 == 0){
    if(x%3 == 0) x/=3;
    else x/=2;
  }
  return x == 1;
}
vector<lint> arr;
int main(){
  lint n;
  cin>>n;
  for(lint i = 0; i < n ; i++){
    lint temp;
    cin>>temp;
    arr.push_back(temp);
  }
  // cout << result << '\n';
  sort(arr.rbegin(), arr.rend());
  for(lint i = 1; i < n; i++){
    // cout<<arr[0]*6*6*6*6*6*6*6<<endl;
    if(!check((arr[0]*6*6*6*6*6*6*6*6*6*6*6), arr[i])){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long  lint;
const lint N = 123456;

lint lcm(lint a, lint b){
  lint temp = __gcd(a, b);
  return temp ? (a / temp * b) : 0;
}
bool check(lint y, lint z){
  if(y%z != 0) return 0;
  int x = y/z;
  while(x%2 == 0 || x%3 == 0){
    if(x%3 == 0) x/=3;
    else x/=2;
  }
  return x == 1;
}
vector<lint> arr;
int main(){
  lint n;
  cin>>n;
  for(lint i = 0; i < n ; i++){
    lint temp;
    cin>>temp;
    arr.push_back(temp);
  }
  // cout << result << '\n';
  sort(arr.rbegin(), arr.rend());
  for(lint i = 1; i < n; i++){
    // cout<<arr[0]*6*6*6*6*6*6*6<<endl;
    if(!check((arr[0]*6*6*6*6*6*6*6), arr[i])){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long  lint;
const lint N = 123456;

lint lcm(lint a, lint b){
  lint temp = __gcd(a, b);
  return temp ? (a / temp * b) : 0;
}
bool check(lint x){
  while(x%2 == 0 || x%3 == 0){
    if(x%3 == 0) x/=3;
    else x/=2;
  }
  return x == 1;
}
vector<lint> a;
int main(){
  lint n;
  cin>>n;
  for(lint i = 0; i < n ; i++){
    lint temp;
    cin>>temp;
    a.push_back(temp);
  }
  lint gcd = a[0];
  for(lint i = 0; i < n; i++){
    gcd = __gcd(gcd, a[i]);
  }
  lint lc = a[0]/gcd;
  for(lint i = 1; i < n; i++){
    lc = lcm(lc, a[i]/gcd);
  }
  if(check(lc))
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long  lint;
const lint N = 123456;

lint lcm(lint a, lint b){
  lint temp = __gcd(a, b);
  return temp ? (a / temp * b) : 0;
}
bool check(lint x){
  while(x%2 == 0 || x%3 == 0){
    if(x%3 == 0) x/=3;
    else x/=2;
  }
  return x == 1;
}
lint arr[N];
int main(){
  lint n;
  cin>>n;
  for(lint i = 0; i < n ; i++) cin>>arr[i];
  lint result = accumulate(arr, arr + n, 1, lcm);
  // cout << result << '\n';
  for(lint i = 0; i < n; i++){
    if(!check(result/arr[i])){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 123456;
int a[N];
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  int gcd = 0;
  for(int i =0 ;i < n;i++){
    cin>>a[i];
    gcd = __gcd(a[i], gcd);
  }
  for(int i =0 ;i < n;i++){
    a[i] /= gcd;
    // gcd = __gcd(a[i], gcd);
    // cout<<a[i]<<" ";
  }
  // cout<<endl;
  for(int i=0; i< n; i++){
    while(a[i] > 1){
      if(a[i]%2 == 0) a[i] = a[i]/2;
      else if(a[i]%3 == 0) a[i] = a[i]/3;
      else{
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long  lint;
const lint N = 123456;

lint lcm(lint a, lint b){
  lint temp = __gcd(a, b);
  return temp ? (a / temp * b) : 0;
}
bool check(lint y, lint z){
  if(y%z != 0) return 0;
  int x = y/z;
  while(x%2 == 0 || x%3 == 0){
    if(x%3 == 0) x/=3;
    else x/=2;
  }
  return x == 1;
}
vector<lint> arr;
int main(){
  lint n;
  cin>>n;
  for(lint i = 0; i < n ; i++){
    lint temp;
    cin>>temp;
    arr.push_back(temp);
  }
  // cout << result << '\n';
  sort(arr.rbegin(), arr.rend());
  for(lint i = 1; i < n; i++){
    // cout<<arr[0]*6*6*6*6*6*6*6<<endl;
    if(!check((arr[0]*6*6*6*6*6*6*6*6*6*6*6*6), arr[i])){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long  lint;
const lint N = 123456;

lint lcm(lint a, lint b){
  lint temp = __gcd(a, b);
  return temp ? (a / temp * b) : 0;
}
bool check(lint y, lint z){
  if(y%z != 0) return 0;
  int x = y/z;
  while(x%2 == 0 || x%3 == 0){
    if(x%3 == 0) x/=3;
    else x/=2;
  }
  return x == 1;
}
vector<lint> arr;
int main(){
  lint n;
  cin>>n;
  for(lint i = 0; i < n ; i++){
    lint temp;
    cin>>temp;
    arr.push_back(temp);
  }
  // cout << result << '\n';
  sort(arr.rbegin(), arr.rend());
  for(lint i = 1; i < n; i++){
    // cout<<arr[0]*6*6*6*6*6*6*6<<endl;
    if(!check((arr[0]*6*6*6*6*6*6*6*6*6), arr[i])){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int a[1000];
int n;

int nod(int a, int b)
{
    while(a > 0 && b > 0)

        if(a > b)
        {
            a %= b;
        }
        else
        {
            b %= a;
        }
    return a + b;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int ans = a[0];
    for (int i = 1; i < n; i++)
    {
        ans = nod(ans, a[i]);
    }
    int fl = true;
    for (int i =0; i < n; i++)
    {
        int k1 = a[i] / ans;
        if (k1 % 3 != 0 && k1 % 2 != 0)
        {
            fl = false;
        }
    }
    if (fl)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
 	return 0;
}


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

long long a[100000];
long long n;

long long nod (int a, int b)
{
        if (b == 0)
                return a;
        else
                return nod (b, a % b);
}

bool krat(long long a)
{
    while (a > 1)
    {
        if (a % 2 == 0)
            a = a / 2;
        if (a % 3 == 0)
            a = a / 3;
        if (a % 2 != 0 && a % 3 != 0 && a != 1)
            return false;
    }
    return true;
}

int main()
{
	cin >> n;
	for (long long i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    long long ans = a[0];
    for (long long i = 1; i < n; i++)
    {
        ans = nod(ans, a[i]);
    }
    bool fl = true;
    for (long long i = 0; i < n; i++)
    {
        long long k1 = a[i] / ans;
        if (k1 != 1 && !krat(k1))
        {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
 	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int a[1000];
int n;

int nod(int a, int b)
{
    while(a > 0 && b > 0)

        if(a > b)
        {
            a %= b;
        }
        else
        {
            b %= a;
        }
    return a + b;
}

bool krat(int a)
{
    //if (a == 1)
       // return false;
    while (a > 1)
    {
        if (a % 2 == 0)
            a = a / 2;
        if (a % 3 == 0)
            a = a / 3;
        if (a % 2 != 0 && a % 3 != 0 && a != 1)
            return false;
    }
    return true;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int ans = a[0];
    for (int i = 1; i < n; i++)
    {
        ans = nod(ans, a[i]);
    }
    int fl = true;
    for (int i = 0; i < n; i++)
    {
        int k1 = a[i] / ans;
        //cout << krat(3);
        if (k1 != 1 && !krat(k1))
        {
            fl = false;
        }
    }
   // cout << ans;
    if (fl)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
 	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int a[1000];
int n;

int nod(int a, int b)
{
    while(a > 0 && b > 0)

        if(a > b)
        {
            a %= b;
        }
        else
        {
            b %= a;
        }
    return a + b;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int ans = a[0];
    for (int i = 1; i < n; i++)
    {
        ans = nod(ans, a[i]);
    }
    int fl = true;
    for (int i = 0; i < n; i++)
    {
        int k1 = a[i] / ans;
        if (k1 % 3 != 0 && k1 % 2 != 0 && k1 != 1)
        {
            fl = false;
        }
    }
    if (fl)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
 	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int a[1000];
int n;

int nod(int a, int b)
{
    while(a > 0 && b > 0)

        if(a > b)
        {
            a %= b;
        }
        else
        {
            b %= a;
        }
    return a + b;
}

bool krat(int a)
{
    while (a > 1)
    {
        if (a % 2 == 0)
            a = a / 2;
        if (a % 3 == 0)
            a = a / 3;
        if (a % 2 != 0 && a % 3 != 0)
            return false;
    }
    return true;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int ans = a[0];
    for (int i = 1; i < n; i++)
    {
        ans = nod(ans, a[i]);
    }
    int fl = true;
    for (int i = 0; i < n; i++)
    {
        int k1 = a[i] / ans;
        if (k1 % 3 != 0 && k1 % 2 != 0 && k1 != 1 && !krat(k1))
        {
            fl = false;
        }
    }
    if (fl)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
 	return 0;
}


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

long long a[1000];
long long n;

long long nod (int a, int b)
{
        if (b == 0)
                return a;
        else
                return nod (b, a % b);
}

bool krat(long long a)
{
    while (a > 1)
    {
        if (a % 2 == 0)
            a = a / 2;
        if (a % 3 == 0)
            a = a / 3;
        if (a % 2 != 0 && a % 3 != 0 && a != 1)
            return false;
    }
    return true;
}

int main()
{
	cin >> n;
	for (long long i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    long long ans = a[0];
    for (long long i = 1; i < n; i++)
    {
        ans = nod(ans, a[i]);
    }
    bool fl = true;
    for (long long i = 0; i < n; i++)
    {
        long long k1 = a[i] / ans;
        if (k1 != 1 && !krat(k1))
        {
            fl = false;
        }
    }
    if (fl)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
 	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long a[1000];
long long n;

long long nod(long long a, long long b)
{
    while(a > 0 && b > 0)

        if(a > b)
        {
            a %= b;
        }
        else
        {
            b %= a;
        }
    return a + b;
}

bool krat(long long a)
{
    while (a > 1)
    {
        if (a % 2 == 0)
            a = a / 2;
        if (a % 3 == 0)
            a = a / 3;
        if (a % 2 != 0 && a % 3 != 0 && a != 1)
            return false;
    }
    return true;
}

int main()
{
	cin >> n;
	for (long long i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    long long ans = a[0];
    for (long long i = 1; i < n; i++)
    {
        ans = nod(ans, a[i]);
    }
    bool fl = true;
    for (long long i = 0; i < n; i++)
    {
        long long k1 = a[i] / ans;
        if (k1 != 1 && !krat(k1))
        {
            fl = false;
        }
    }
    if (fl)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
 	return 0;
}


#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <climits>
#include <set>
#include <queue>
#define v1 (2*v+1)
#define v2 (2*v+2)
//#define ll long long
using ll = long long;
#define forn(it, a, b) for(auto it = a; it < b; it++)
#define mp(x, y) make_pair(x, y)
using namespace std;

#if _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

ll mx = -1;

bool f(ll k)
{
	if (k > mx)
		return false;
	if (k == mx)
		return true;
	return (f(2 * k) || f(3 * k));
}

int main()
{
	//
	ios::sync_with_stdio(false);
	//
	int n;
	cin >> n;
	vector <ll> v(n);
	forn(i, 0, n)
	{
		cin >> v[i];
		mx = max(mx, v[i]);
	}
	for (int i = 0; i < n; i++)
	{
		if (!f(v[i]))
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <climits>
#include <set>
#include <queue>
#define v1 (2*v+1)
#define v2 (2*v+2)
//#define ll long long
using ll = long long;
#define forn(it, a, b) for(auto it = a; it < b; it++)
#define mp(x, y) make_pair(x, y)
using namespace std;

#if _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

ll mx = -1;

bool f(ll k)
{
	if (k > mx)
	{
		return false;
	}
	if (k == mx)
		return true;
	return (f(2 * k) || f(3 * k));
}

int main()
{
	//
	ios::sync_with_stdio(false);
	//
	int n;
	cin >> n;
	int v, t;
	cin >> v;
	while (v % 2 == 0) v /= 2;
	while (v % 3 == 0) v /= 3;
	forn(i, 0, n - 1)
	{
		cin >> t;
		while (t % 2 == 0) t /= 2;
		while (t % 3 == 0) t /= 3;
		if (t != v)
		{
			cout << "No";
			break;
		}
	}
	cout << "Yes";
	return 0;
}


#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <climits>
#include <set>
#include <queue>
#define v1 (2*v+1)
#define v2 (2*v+2)
//#define ll long long
using ll = long long;
#define forn(it, a, b) for(auto it = a; it < b; it++)
#define mp(x, y) make_pair(x, y)
using namespace std;

#if _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

ll mx = -1;

bool f(ll k)
{
	if (k > mx)
	{
		return false;
	}
	if (k == mx)
		return true;
	return (f(2 * k) || f(3 * k));
}

int main()
{
	//
	ios::sync_with_stdio(false);
	//
	int n;
	cin >> n;
	vector <ll> v(n);
	forn(i, 0, n)
	{
		cin >> v[i];
		mx = max(mx, v[i]);
	}
	mx = mx * pow(2, 8) * pow(3, 8);
	for (int i = 0; i < n; i++)
	{
		if (!f(v[i]))
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <climits>
#include <set>
#include <queue>
#define v1 (2*v+1)
#define v2 (2*v+2)
//#define ll long long
using ll = long long;
#define forn(it, a, b) for(auto it = a; it < b; it++)
#define mp(x, y) make_pair(x, y)
using namespace std;

#if _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

ll mx = -1;

bool f(ll k)
{
	if (k > mx)
	{
		return false;
	}
	if (k == mx)
		return true;
	return (f(2 * k) || f(3 * k));
}

int main()
{
	//
	ios::sync_with_stdio(false);
	//
	int n;
	cin >> n;
	int v, t;
	cin >> v;
	while (v % 2 == 0) v /= 2;
	while (v % 3 == 0) v /= 3;
	forn(i, 0, n - 1)
	{
		cin >> t;
		while (t % 2 == 0) t /= 2;
		while (t % 3 == 0) t /= 3;
		if (t != v)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <climits>
#include <set>
#include <queue>
#define v1 (2*v+1)
#define v2 (2*v+2)
//#define ll long long
using ll = long long;
#define forn(it, a, b) for(auto it = a; it < b; it++)
#define mp(x, y) make_pair(x, y)
using namespace std;

#if _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

int mx = -1;

bool f(int k)
{
	if (k > mx)
		return false;
	if (k == mx)
		return true;
	return (f(2 * k) || f(3 * k));
}

int main()
{
	//
	ios::sync_with_stdio(false);
	//
	int n;
	cin >> n;
	vector <int> v(n);
	forn(i, 0, n)
	{
		cin >> v[i];
		mx = max(mx, v[i]);
	}
	for (int i = 0; i < n; i++)
	{
		if (!f(v[i]))
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <climits>
#include <set>
#include <queue>
#define v1 (2*v+1)
#define v2 (2*v+2)
//#define ll long long
using ll = long long;
#define forn(it, a, b) for(auto it = a; it < b; it++)
#define mp(x, y) make_pair(x, y)
using namespace std;

#if _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

ll mx = -1;

bool f(ll k)
{
	if (k > mx)
	{
		return false;
	}
	if (k == mx)
		return true;
	return (f(2 * k) || f(3 * k));
}

int main()
{
	//
	ios::sync_with_stdio(false);
	//
	int n;
	cin >> n;
	vector <ll> v(n);
	forn(i, 0, n)
	{
		cin >> v[i];
		mx = max(mx, v[i]);
	}
	mx = mx * 2 * 3 * 2 * 3 * 2 * 3;
	for (int i = 0; i < n; i++)
	{
		if (!f(v[i]))
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


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


# include <bits/stdc++.h>
using namespace std;
long long a[200000];
int main()
{
    long long n  , max1 = -1 , i , s;
    cin>> n>> a[1];
    max1 = a[1];
    for(i = 2 ; i <= n ; i ++)
        cin>> a[i] , max1 = ((max1 * a[i]) / (__gcd(max1 , a[i])));
    for(i = 1 ; i <= n ; i ++){
        s = max1 / a[i];
        while(s % 2 == 0)
            s /= 2;
        while(s % 3 == 0)
            s /= 3;
        if(s != 1){cout<<"No";return 0;}
    }
    cout<<"Yes";
}


#include <bits/stdc++.h>
using namespace std;
const int N = 123456;
int main() {
    int n;
    char ans[][4]={"NO","YES"};
    cin >> n;
    set<int>st;
    for(int i=0;i<n;++i){
        int x;
        cin >> x;
        while((x&1)==0)x>>=1;
        while(x %3==0)x/=3;
        st.insert(x);
    }
    puts(ans[st.size()==1]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 123456;
int main() {
#ifndef ONLINE_JUDGE
    freopen("a.in", "r", stdin);
#endif
    int n;
    char ans[][4]={"NO","YES"};
    cin >> n;
    set<int>st;
    for(int i=0;i<n;++i){
        int x;
        cin >> x;
        while(x&1)x>>=1;
        while(x %3==0)x/=3;
        st.insert(x);
    }
    puts(ans[st.size()==1]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 123456;
int main() {
    int n;
    char ans[][4]={"NO","YES"};
    cin >> n;
    set<int>st;
    for(int i=0;i<n;++i){
    	int x;
    	cin >> x;
    	while(x&1)x>>=1;
    	while(x %3==0)x/=3;
    	st.insert(x);
    }
    puts(ans[st.size()==1]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1234567;

map<ll, int> cnt;
int main() {
#ifndef ONLINE_JUDGE
    freopen("a.in", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        queue<ll > que;
        map<ll, int> vist;
        que.push(x);
        vist[x] = 1;
        while (que.size()) {
            ll y = que.front();
            que.pop();
            cnt[y]++;
            if (cnt[y] == n) {
                cout << "Yes";
                return 0;
            }
            ll tmp = y * 3LL;
            if (tmp > 0 && tmp < LONG_MAX && vist.find(tmp) == vist.end()) {
                vist[tmp] = 1;
                que.push(tmp);

            }
            tmp = y * 2LL;
            if (tmp > 0 && tmp < LONG_MAX && vist.find(tmp) == vist.end()) {
                vist[tmp] = 1;
                que.push(tmp);
            }
        }
    }
    cout << "No";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 123456;
int main() {
#ifndef ONLINE_JUDGE
    freopen("a.in", "r", stdin);
#endif
    int n;
    char ans[][4] = { "NO", "YES" };
    cin >> n;
    set<int> st;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        while (!(x&1))
            x >>= 1;
        while (x % 3 == 0)
            x /= 3;
        st.insert(x);
    }
    for (set<int>::iterator it = st.begin(); it != st.end(); ++it)
        cout << *it << " ";
    puts(ans[st.size() == 1]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1234567;

map<ll, int> cnt;
int main() {
#ifndef ONLINE_JUDGE
    freopen("a.in", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        queue<ll > que;
        map<ll, int> vist;
        que.push(x);
        vist[x] = 1;
        while (que.size()) {
            ll y = que.front();
            que.pop();
            cnt[y]++;
            if (cnt[y] == n) {
                cout << "Yes";
                return 0;
            }
            if (y * 2 < 1000000000000LL && vist.find(y * 2) == vist.end()) {
                vist[y * 2] = 1;
                que.push(y * 2);
            }
            if (y * 3 < 1000000000000LL && vist.find(y * 3) == vist.end()) {
                vist[y * 3] = 1;
                que.push(y * 2);
            }
        }
    }
    cout << "No";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1234567;

map<ll, int> cnt;
int main() {
#ifndef ONLINE_JUDGE
    freopen("a.in", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        queue<ll > que;
        map<ll, int> vist;
        que.push(x);
        vist[x] = 1;
        while (que.size()) {
            ll y = que.front();
            que.pop();
            cnt[y]++;
            if (cnt[y] == n) {
                cout << "Yes";
                return 0;
            }
            ll tmp = y * 3LL;
            if (tmp > 0 && tmp < LLONG_MAX && vist.find(tmp) == vist.end()) {
                vist[tmp] = 1;
                que.push(tmp);

            }
            tmp = y * 2LL;
            if (tmp > 0 && tmp < LLONG_MAX && vist.find(tmp) == vist.end()) {
                vist[tmp] = 1;
                que.push(tmp);
            }
        }
    }
    cout << "No";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1234567;

map<ll, int> cnt;
int main() {
#ifndef ONLINE_JUDGE
    freopen("a.in", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        queue<ll > que;
        map<ll, int> vist;
        que.push(x);
        vist[x] = 1;
        while (que.size()) {
            ll y = que.front();
            que.pop();
            cnt[y]++;
            if (cnt[y] == n) {
                cout << "Yes";
                return 0;
            }
            ll tmp = y * 3LL;
            if (tmp > 0 && tmp < 9223372036854775807LL * 3LL && vist.find(tmp) == vist.end()) {
                vist[tmp] = 1;
                que.push(tmp);

            }
            tmp = y * 2LL;
            if (tmp > 0 && tmp < 9223372036854775807LL * 3LL && vist.find(tmp) == vist.end()) {
                vist[tmp] = 1;
                que.push(tmp);
            }
        }
    }
    cout << "No";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1234567;

map<ll, int> cnt;
int main() {
#ifndef ONLINE_JUDGE
    freopen("a.in", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        queue<ll > que;
        map<ll, int> vist;
        que.push(x);
        vist[x] = 1;
        while (que.size()) {
            ll y = que.front();
            que.pop();
            cnt[y]++;
            if (cnt[y] == n) {
                cout << "Yes";
                return 0;
            }
            if (y * 3LL < 1000000000000000LL && vist.find(y * 3LL) == vist.end()) {
                vist[y * 3LL] = 1;
                que.push(y * 3LL);
            }
            if (y * 3LL < 1000000000000000LL && vist.find(y * 3LL) == vist.end()) {
                vist[y * 3LL] = 1;
                que.push(y * 3LL);
            }
        }
    }
    cout << "No";
    return 0;
}


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

typedef long long ll;

int n, a[100000];

ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}

inline bool check(ll src, ll dest) {
    while (src < dest)
        src <<= 1LL;
    return src == dest;
}

int main() {
//  freopen("a", "r", stdin);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    ll all = 1;
    for (int i = 0; i < n; ++i)
        all = lcm(all, a[i]);
    bool can = true;
    for (int i = 0; i < n && can; ++i)
        can &= check(a[i], all) || check(a[i] * 3, all);
    if (can)
        puts("YES");
    else
        puts("NO");
    return 0;
}


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

typedef long long ll;

int n, a[100000];

ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}

inline bool check(ll src, ll dest) {
    while (src < dest)
        src <<= 1LL;
    return src == dest;
}

int main() {
//  freopen("a", "r", stdin);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    ll all = 1;
    for (int i = 0; i < n; ++i)
        all = lcm(all, a[i]);
    bool can = true;
    for (int i = 0; i < n && can; ++i)
        can &= check(a[i], all) || check(a[i] * 3LL, all);
    if (can)
        puts("YES");
    else
        puts("NO");
    return 0;
}


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

typedef long long ll;

int n, a[100000];

ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}

inline bool check(ll src, ll dest, ll mul) {
    while (src < dest)
        src *= mul;
    return src == dest;
}

int main() {
//  freopen("a", "r", stdin);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    ll all = 1;
    for (int i = 0; i < n; ++i)
        all = lcm(all, a[i]);
    bool can = true;
    for (int i = 0; i < n && can; ++i)
        can &= check(a[i], all, 2) || check(a[i], all, 3);
    if (can)
        puts("YES");
    else
        puts("NO");
    return 0;
}


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

typedef long long ll;

int n, a[100000];

inline ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}

bool check(ll val) {
    int a[] = { 2, 3 };
    for (int i = 0; i < 2; ++i)
        while (val % a[i] == 0)
            val /= a[i];
    return val == 1;
}

int main() {
//  freopen("a", "r", stdin);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    ll all = 1;
    for (int i = 0; i < n; ++i)
        all = lcm(all, a[i]);
    bool can = true;
    for (int i = 0; i < n && can; ++i)
        can &= check(all / a[i]);
    if (can)
        puts("YES");
    else
        puts("NO");
    return 0;
}


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

typedef long long ll;

int n, a[100000];

inline ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}

int main() {
//  freopen("a", "r", stdin);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    ll all = 1;
    int mx = *max_element(a, a + n);
    for (int i = 0; i < n; ++i) {
        all = lcm(all, a[i]);
        if (all > mx)
            break;
    }
    if (all == mx)
        puts("YES");
    else
        puts("NO");
    return 0;
}


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

typedef long long ll;

int main() {
//  freopen("a", "r", stdin);
    int n;
    scanf("%d", &n);
    set<int> st;
    for (int i = 0, x; i < n; ++i) {
        scanf("%d", &x);
        while (x % 2 == 0)
            x /= 2;
        while (x % 3 == 0)
            x /= 3;
        st.insert(x);
    }
    if (st.size() == 1)
        puts("YES");
    else
        puts("NO");
    return 0;
}


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

typedef long long ll;

int n, a[100000];

inline ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}

int main() {
//  freopen("a", "r", stdin);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    ll all = 1;
    for (int i = 0; i < n; ++i)
        all = lcm(all, a[i]);
    int mx = *max_element(a, a + n);
    if (all == mx)
        puts("YES");
    else
        puts("NO");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL unsigned long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    if((a * b) / (__gcd(a, b)) > (LL)1e27)
        return 1;
    return (a * b) / (__gcd(a, b));
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        if(x == 0) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 31; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL unsigned long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    if((a * b) / (__gcd(a, b)) > (int)1e10)
        return (LL)1e27;
    return (a * b) / (__gcd(a, b));
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        if(L == (LL)1e27) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 31; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL unsigned long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
	LL g = __gcd(a, b);
	double x = log(g*1.0);
	double y = log(a * 1.0) + log( b * 1.0);
	if( y - x >= 62) return 0;
	return a/g * b;
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        if(x == 0) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 50; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    if((a * b) / (__gcd(a, b)) > (int)1e10)
        return (LL)1e10;
    return (a * b) / (__gcd(a, b));
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        if(L == (LL)1e10) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 31; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    if((a * b) / (__gcd(a, b)) > (int)1e10)
        return (LL)1e18;
    return (a * b) / (__gcd(a, b));
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        if(L == (LL)1e18) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 31; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    return (a * b) / (__gcd(a, b));
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        for(int j = 0; j < 31; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL unsigned long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    LL g = __gcd(a, b);
    double x = log2(g*1.0);
    double y = log2(a * 1.0) + log2( b * 1.0);
    if( y - x > 62) return 0;
    return a/g * b;
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int cnt = 0, cnt1 = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        L = lcm(L, a[i]);
    }
    for(int i = 0; i < n; i++) {
        LL x = L / a[i];
        if(x == 0) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 50; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL unsigned long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    if((a * b) / (__gcd(a, b)) > (LL)1e27)
        return 1;
    return (a * b) / (__gcd(a, b));
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        if(x == 0) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 31; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL unsigned long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    if((a * b) / (__gcd(a, b)) > (LL)1e27)
        return (LL)1e27;
    return (a * b) / (__gcd(a, b));
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        if(L == (LL)1e27) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 31; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL unsigned long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    if((a * b) / (__gcd(a, b)) > (LL)1e27)
        return 1;
    return (a * b) / (__gcd(a, b));
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        if(x == 0) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 31; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL unsigned long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    if((a * b) / (__gcd(a, b)) > (LL)1e27)
        return 1;
    return (a * b) / (__gcd(a, b));
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        if(x == 0) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 31; j++) {
            if(x > 1) {
            if(x % 2 != 0 || x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL unsigned long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    LL g = __gcd(a, b);
    double x = log(g*1.0);
    double y = log(a * 1.0) + log( b * 1.0);
    if( y - x > 62) return 0;
    return a/g * b;
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        if(x == 0) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 31; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL unsigned long long
#define mod (int)1e9+7
#define sqr(x) ((x)*(x))

using namespace std;

LL lcm(LL a, LL b) {
    LL g = __gcd(a, b);
    double x = log(g*1.0);
    double y = log(a * 1.0) + log( b * 1.0);
    if( y - x > 63) return 0;
    return a/g * b;
}

LL n, a[112345], L = 1;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int i = 0; i < n; i++) {
        LL x = L / a[i];

        if(x == 0) {
            cout << "No" << endl;
            return 0;
        }

        for(int j = 0; j < 31; j++) {
            if(x > 1) {
            if(x % 2 != 0 && x % 3 != 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(x % 2 == 0)
                    x /= 2;
                if(x % 3 == 0)
                    x /= 3;
            }
            }
            else
                break;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#define pb push_back
#define ll long long int

#include<bits/stdc++.h>
using namespace std;
stack<ll>st;
vector<ll>v;
set<ll>s;

int main()
{
	ll i,n,x,m,y=0;
	cin>>n;
	while(n--)
	{
		cin>>x;
		s.insert(x);
	}

	for(set < ll >:: iterator i=s.begin();i!=s.end();i++)v.pb(*i);
//	reverse(v.begin(),v.end());
	//for(vector<ll>::iterator i=v.begin();i!=v.end();i++)cout<<*i<<" ";
    m=v[0];
    while(v[0]%2==0)v[0]/=2;
    while(v[0]%3==0)v[0]/=3;
    m=v[0];
	for(i=1;i<v.size();i++)
	{
        n=v[i];
       while(v[i]%2==0)v[i]/=2;
       while(v[i]%3==0)v[i]/=3;
       n=v[i];
		if(v[i]!=v[i-1]){y=1;break;}

	}

if(v.size()==1)cout<<"Yes"<<endl;
   else	if(y)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


#define pb push_back
#define ll long long int

#include<bits/stdc++.h>
using namespace std;
stack<ll>st;
vector<ll>v;
set<ll>s;

int main()
{
	ll i,n,x,m,y=0;
	cin>>n;
	while(n--)
	{
		cin>>x;
		s.insert(x);
	}

	for(set < ll >:: iterator i=s.begin();i!=s.end();i++)v.pb(*i);
//	reverse(v.begin(),v.end());
	//for(vector<ll>::iterator i=v.begin();i!=v.end();i++)cout<<*i<<" ";

	for(i=0;i<v.size()-1;i++)
	{

		m=v.back();
		if(m%v[i]!=0){y=1;break;}

	}

if(v.size()==1)cout<<"Yes"<<endl;
   else	if(y)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


#define pb push_back
#define ll long long int

#include<bits/stdc++.h>
using namespace std;
stack<ll>st;
vector<ll>v;
set<ll>s;
ll gcd(ll x,ll y)
{
	if(y==0)return x;
	gcd(y,x%y);
}

int main()
{
	ll i,n,x,m,y=0;
	cin>>n;
	while(n--)
	{
		cin>>x;
		s.insert(x);
	}

	for(set < ll >:: iterator i=s.begin();i!=s.end();i++)v.pb(*i);
//	reverse(v.begin(),v.end());
	//for(vector<ll>::iterator i=v.begin();i!=v.end();i++)cout<<*i<<" ";

	for(i=0;i<v.size()-1;i++)
	{

		m=v.back();
		if(m%v[i]!=0){y=1;break;}

	}

if(v.size()==1)cout<<"Yes"<<endl;
   else	if(y)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


#define pb push_back
#define ll long long int

#include<bits/stdc++.h>
using namespace std;
stack<ll>st;
vector<ll>v;
set<ll>s;
ll gcd(ll x,ll y)
{
	if(y==0)return x;
	gcd(y,x%y);
}

int main()
{
	ll i,n,x,m,y;
	cin>>n;
	while(n--)
	{
		cin>>x;
		s.insert(x);
	}

	for(set < ll >:: iterator i=s.begin();i!=s.end();i++)v.pb(*i);

	for(i=1;i<v.size()-1;i++)
	{

		m=v[i];
		y=v[i-1];
		ll p=gcd(m,y);
		 p=m*y/p;
		 v[i]=p;
	}
        m=v[i];
        y=v[i-1];

	if(!(v[i]%v[i-1])||!(v[i-1]%v[i]))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


#define pb push_back
#define ll long long int

#include<bits/stdc++.h>
using namespace std;
stack<ll>st;
vector<ll>v;
set<ll>s;
ll gcd(ll x,ll y)
{
	if(y==0)return x;
	gcd(y,x%y);
}

int main()
{
	ll i,n,x,m,y=0;
	cin>>n;
	while(n--)
	{
		cin>>x;
		s.insert(x);
	}

	for(set < ll >:: iterator i=s.begin();i!=s.end();i++)v.pb(*i);
//	reverse(v.begin(),v.end());
	//for(vector<ll>::iterator i=v.begin();i!=v.end();i++)cout<<*i<<" ";

	for(i=0;i<v.size()-1;i++)
	{

		m=v.back();
		if(gcd(m,v[i])==1){y=1;break;}

	}

if(v.size()==1)cout<<"Yes"<<endl;
   else	if(y)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);

	int a;
	scanf("%d", a);
	while (a % 2 == 0) a /= 2;
	while (a % 3 == 0) a /= 3;

	for (int i = 1, b; i < n; i++)
	{
		scanf("%d", &b);

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

		if (a != b)
		{
			puts("No");
			return 0;
		}
	}

	puts("Yes");
}


#include <iostream>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;

	int a = -1;
	bool all_equal = true;
	for (int i = 0; i < n; i++)
	{
		int b;
		cin >> b;

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

		if (a != b && a != -1)
			all_equal = false;

		a = b;
	}

	cout << (all_equal ? "Yes" : "No");
}


#include <iostream>

using namespace std;

int t[100000];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

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

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

	for (int i = 1; i < n; i++) if (t[i] != t[i - 1])
	{
		cout << "No";
		return 0;
	}

	cout << "Yes";
}


#include <iostream>

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);

	int n;
	std::cin >> n;

	int a = -1;
	for (int i = 0, b; i < n; i++)
	{
		std::cin >> b;

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

		if (a != b && a != -1)
		{
			std::cout << "No";
			return 0;
		}

		a = b;
	}

	std::cout << "Yes";
}


#include <iostream>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int t[100000];
int main()
{
	int n;
	cin >> n;

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

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

	for (int i = 1; i < n; i++) if (t[i] != t[i - 1])
	{
		cout << "No";
		return 0;
	}

	cout << "Yes";
}


#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);

	int a = -1;
	for (int i = 0, b; i < n; i++)
	{
		scanf("%d", &b);

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

		if (a != b && a != -1)
		{
			puts("No");
			return 0;
		}

		a = b;
	}

	puts("Yes");
}


#include <iostream>

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);

	int n;
	std::cin >> n;

	int a = -1;
	for (int i = 0; i < n; i++)
	{
		int b;
		std::cin >> b;

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

		if (a != b && a != -1)
		{
			std::cout << "No";
			return 0;
		}

		a = b;
	}

	std::cout << "Yes";
}


#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);

	int a;
	scanf("%d", &a);
	while (a % 2 == 0) a /= 2;
	while (a % 3 == 0) a /= 3;

	for (int i = 1, b; i < n; i++)
	{
		scanf("%d", &b);

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

		if (a != b)
		{
			puts("No");
			return 0;
		}
	}

	puts("Yes");
}


#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);

	int a = -1;
	for (int i = 0, b; i < n; i++)
	{
		scanf("%d", &b);

		while ((b & 1) == 0) b >>= 1;
		while (b % 3 == 0) b /= 3;

		if (a != b && a != -1)
		{
			puts("No");
			return 0;
		}

		a = b;
	}

	puts("Yes");
}


#include <iostream>

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);

	int n;
	std::cin >> n;

	int a = -1;
	for (int i = 0, b; i < n; i++)
	{
		std::cin >> b;

		while ((b & 1) == 0) b >>= 1;
		while (b % 3 == 0) b /= 3;

		if (a != b && a != -1)
		{
			std::cout << "No";
			return 0;
		}

		a = b;
	}

	std::cout << "Yes";
}


#include <iostream>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int t[100000];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

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

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

	for (int i = 1; i < n; i++) if (t[i] != t[i - 1])
	{
		cout << "No";
		return 0;
	}

	cout << "Yes";
}


#include <iostream>

int t[100000];
int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);

	int n;
	std::cin >> n;

	for (int i = 0; i < n; i++)
	{
		std::cin >> t[i];

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

	for (int i = 1; i < n; i++) if (t[i] != t[i - 1])
	{
		std::cout << "No";
		return 0;
	}

	std::cout << "Yes";
}


#include <iostream>

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);

	int n;
	std::cin >> n;

	int a = -1;
	for (int i = 0; i < n; i++)
	{
		int b;
		std::cin >> b;

		while (b | 1 == 0) b >>= 1;
		while (b % 3 == 0) b /= 3;

		if (a != b && a != -1)
		{
			std::cout << "No";
			return 0;
		}

		a = b;
	}

	std::cout << "Yes";
}


#include <iostream>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;

	int a = -1;
	for (int i = 0; i < n; i++)
	{
		int b;
		cin >> b;

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

		if (a != b && a != -1)
		{
			cout << "No";
			return 0;
		}

		a = b;
	}

	cout << "Yes";
}


#include <bits/stdc++.h>

using namespace std;

unsigned long long gcd (unsigned long long n1, unsigned long long n2)
{
    return (n2 == 0) ? n1 : gcd (n2, n1 % n2);
}
long long ar[100000],ar2[00000];
bool ar3[1000000001]= {0};
int main()
{
    long long a;
    cin>>a;
    long long aux=1,xxx;
    ar3[1]=1;
    ar3[0]=0;
    for(long long i=1; i<1000; i++)
    {
        xxx=aux;
        for(long long j=1; j<1000; j++)
        {
            if(xxx>=1000000000)break;
            ar3[xxx]=1;
            xxx=xxx*3;
        }
        aux=aux*2;
    }
    for(long long i=0; i<a; i++)cin>>ar[i];
    long long lol=ar[0];
    for(long long i=0; i<a; i++)lol=gcd(lol,ar[i]);
    //cout<<lol<<endl;
    for(long long i=0; i<a; i++)ar2[i]=ar[i]/lol;
    long long cont=6;
    for(long long i=0; i<a; i++)
    {
        //cout<<ar2[i]<<" ";
        cont=cont*ar2[i];
    }
    for(long long i=0; i<a; i++)
    {
        if(ar3[ar2[i]]==1);
        else
        {
            cout<<"No"<<endl;
            goto gnu;
        }
    }
    cout<<"Yes"<<endl;
gnu:
    ;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

unsigned int gcd (unsigned int n1, unsigned int n2)
{
    return (n2 == 0) ? n1 : gcd (n2, n1 % n2);
}
int ar[100000],ar2[00000];
int main()
{
    int a;
    cin>>a;
    for(int i=0; i<a; i++)cin>>ar[i];
    int lol=ar[0];
    for(int i=0; i<a; i++)lol=gcd(lol,ar[i]);
    //cout<<lol<<endl;
    for(int i=0; i<a; i++)ar2[i]=ar[i]/lol;
    int cont=1;
    for(int i=0; i<a; i++)
    {
        //cout<<ar2[i]<<" ";
        cont=cont*ar2[i];
    }
    int cont2;
    for(int i=0;i<a;i++)
    {
        cont2=cont/ar2[i];
        while(cont2!=1)
        {
            if(cont2%2==0 or cont2%3==0);
            else {
            cout<<"No"<<endl;
            goto gnu;
            }
            if(cont2%2==0)cont2=cont2/2;
            if(cont2%3==0)cont2=cont2/3;
        }
    }
    cout<<"Yes"<<endl;
    gnu:;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

unsigned int gcd (unsigned int n1, unsigned int n2)
{
    return (n2 == 0) ? n1 : gcd (n2, n1 % n2);
}
int ar[100000],ar2[00000];
bool ar3[1000000001]= {0};
int main()
{
    long long a;
    cin>>a;
    long long aux=1,xxx;
    ar3[1]=1;
    ar3[0]=0;
    for(long long i=1; i<1000; i++)
    {
        xxx=aux;
        for(long long j=1; j<1000; j++)
        {
            if(xxx>=1000000000)break;
            ar3[xxx]=1;
            xxx=xxx*3;
        }
        aux=aux*2;
    }
    for(long long i=0; i<a; i++)cin>>ar[i];
    long long lol=ar[0];
    for(long long i=0; i<a; i++)lol=gcd(lol,ar[i]);
    //cout<<lol<<endl;
    for(long long i=0; i<a; i++)ar2[i]=ar[i]/lol;
    long long cont=6;
    for(long long i=0; i<a; i++)
    {
        //cout<<ar2[i]<<" ";
        cont=cont*ar2[i];
    }
    for(int i=0; i<a; i++)
    {
        if(ar3[ar2[i]]==1);
        else
        {
            cout<<"No"<<endl;
            goto gnu;
        }
    }
    cout<<"Yes"<<endl;
gnu:
    ;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

unsigned int gcd (unsigned int n1, unsigned int n2)
{
    return (n2 == 0) ? n1 : gcd (n2, n1 % n2);
}
int ar[100000],ar2[00000];
bool ar3[100000001]= {0};
int main()
{
    long long a;
    cin>>a;
    long long aux=1,xxx;
    ar3[1]=1;
    ar3[0]=0;
    for(long long i=1; i<1000; i++)
    {
        xxx=aux;
        for(long long j=1; j<1000; j++)
        {
            if(xxx>=100000000)break;
            ar3[xxx]=1;
            xxx=xxx*3;
        }
        aux=aux*2;
    }
    for(long long i=0; i<a; i++)cin>>ar[i];
    long long lol=ar[0];
    for(long long i=0; i<a; i++)lol=gcd(lol,ar[i]);
    //cout<<lol<<endl;
    for(long long i=0; i<a; i++)ar2[i]=ar[i]/lol;
    long long cont=6;
    for(long long i=0; i<a; i++)
    {
        //cout<<ar2[i]<<" ";
        cont=cont*ar2[i];
    }
    for(int i=0; i<a; i++)
    {
        if(ar3[ar2[i]]==1);
        else
        {
            cout<<"No"<<endl;
            goto gnu;
        }
    }
    cout<<"Yes"<<endl;
gnu:
    ;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

unsigned int gcd (unsigned int n1, unsigned int n2)
{
    return (n2 == 0) ? n1 : gcd (n2, n1 % n2);
}
int ar[100000],ar2[00000];

int main()
{
    long long a;
    cin>>a;
    long long aux=1,xxx;
    map<int,bool> ar3;
    ar3[1]=1;
    for(long long i=1; i<1000; i++)
    {
        xxx=aux;
        for(long long j=1; j<1000; j++)
        {
            if(xxx>=1000000001)break;
            ar3[xxx]=1;
            xxx=xxx*3;
        }
        aux=aux*2;
    }
    for(long long i=0; i<a; i++)cin>>ar[i];
    long long lol=ar[0];
    for(long long i=0; i<a; i++)lol=gcd(lol,ar[i]);
    //cout<<lol<<endl;
    for(long long i=0; i<a; i++)ar2[i]=ar[i]/lol;
    long long cont=6;
    for(long long i=0; i<a; i++)
    {
        //cout<<ar2[i]<<" ";
        cont=cont*ar2[i];
    }
    for(int i=0; i<a; i++)
    {/*
        gnu2:;
        if(ar2[i]>100000000)
        {
            if(ar2[i]%2==0 or ar2[i]%3==0);
            else
            {
                cout<<"No"<<endl;
                goto gnu;
            }
            if(ar2[i]%2==0)ar2[i]=ar2[i]/2;
            if(ar2[i]%3==0)ar2[i]=ar2[i]/3;
            goto gnu2;
        }*/

        if(ar3[ar2[i]]==1);
        else
        {
            cout<<"No"<<endl;
            goto gnu;
        }
    }
    cout<<"Yes"<<endl;
gnu:
    ;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

unsigned int gcd (unsigned int n1, unsigned int n2)
{
    return (n2 == 0) ? n1 : gcd (n2, n1 % n2);
}
int ar[100000],ar2[00000];
bool ar3[100000001]= {0};
int main()
{
    long long a;
    cin>>a;
    long long aux=1,xxx;
    ar3[1]=1;
    ar3[0]=0;
    for(long long i=1; i<1000; i++)
    {
        xxx=aux;
        for(long long j=1; j<1000; j++)
        {
            if(xxx>=100000000)break;
            ar3[xxx]=1;
            xxx=xxx*3;
        }
        aux=aux*2;
    }
    for(long long i=0; i<a; i++)cin>>ar[i];
    long long lol=ar[0];
    for(long long i=0; i<a; i++)lol=gcd(lol,ar[i]);
    //cout<<lol<<endl;
    for(long long i=0; i<a; i++)ar2[i]=ar[i]/lol;
    long long cont=6;
    for(long long i=0; i<a; i++)
    {
        //cout<<ar2[i]<<" ";
        cont=cont*ar2[i];
    }
    for(int i=0; i<a; i++)
    {
        gnu2:;
        if(ar2[i]>100000000)
        {
            if(ar2[i]%2==0 or ar2[i]%3==0);
            else
            {
                cout<<"No"<<endl;
                goto gnu;
            }
            if(ar2[i]%2==0)ar2[i]=ar2[i]/2;
            if(ar2[i]%3==0)ar2[i]=ar2[i]/3;
            goto gnu2;
        }

        if(ar3[ar2[i]]==1);
        else
        {
            cout<<"No"<<endl;
            goto gnu;
        }
    }
    cout<<"Yes"<<endl;
gnu:
    ;
    return 0;
}


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

#define mp make_pair
#define pb push_back
#define INF 1000000000

typedef long long ll;
typedef pair<int,int> pii;
const double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;

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

ll lcm(ll a, ll b)
{
	return a*b/gcd(a,b);
}

int dp[10000000];
vector<int> primes;
void sieve()
{
	for (int i = 2; i < 10000000; i++)
		dp[i] = 1;
	for (int i = 2; i < 10000000; i++)
		for (int j = 2*i; j < 10000000; j+=i)
			dp[j] = 0;
	for (int i = 2; i < 10000000; i++)
		if (dp[i]) primes.push_back(i);
}

bool bate(ll N) { // remember: vi is vector<int>, ll is long long
map<ll,int> factors;
ll PF_idx = 0, PF = primes[PF_idx]; // primes has been populated by sieve
while (PF * PF <= N) { // stop at sqrt(N); N can get smaller
while (N % PF == 0) { N /= PF; if (PF>3) return false; } // remove PF
PF = primes[++PF_idx]; // only consider primes!
}
if (N != 1 && N != 2 && N != 3) return false; // special case if N is a prime
return true; // if N does not fit in 32-bit integer and is a prime
}

int main()
{
	ll N, V[112345];
	sieve();
	cin >> N;
	for (int i = 0; i < N; i++) cin >> V[i];
	sort(V,V+N);
	ll maior = V[N-1];
	for (int i = N-2; i >= 0; i--)
	{
		if (maior%V[i]!=0 && !bate(lcm(maior,V[i])/gcd(maior,V[i])) || maior%V[i]==0 && !bate(maior/V[i]))
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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

#define mp make_pair
#define pb push_back
#define INF 1000000000

typedef long long ll;
typedef pair<int,int> pii;
const double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;

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

ll lcm(ll a, ll b)
{
	return a*b/gcd(a,b);
}

ll N, X, V[112345];
int dp[1000000];
vector<int> primes;
void sieve()
{
	for (int i = 2; i < 1000000; i++)
		dp[i] = 1;
	for (int i = 2; i < 1000000; i++)
		for (int j = 2*i; j < 1000000; j+=i)
			dp[j] = 0;
	for (int i = 2; i < 1000000; i++)
		if (dp[i]) primes.push_back(i);
}

map<int,int> primeFactors(ll N) { // remember: vi is vector<int>, ll is long long
map<int,int> factors;
ll PF_idx = 0, PF = primes[PF_idx]; // primes has been populated by sieve
while (PF * PF <= N) { // stop at sqrt(N); N can get smaller
while (N % PF == 0) { N /= PF; if (PF>3) factors[PF]++; } // remove PF
PF = primes[++PF_idx]; // only consider primes!
}
if (N != 1 && N != 2 && N != 3) factors[N]++; // special case if N is a prime
return factors; // if N does not fit in 32-bit integer and is a prime
}
bool bate(map<int,int> m1, map<int,int> m2)
{
	if (m1.size() != m2.size()) return false;
	for (auto i = m1.begin(); i != m1.end(); i++)
		if (i->second != m2[i->first])
			return false;
	return true;
}
int main()
{
	sieve();
	cin >> N >> X;
	map<int,int> inic = primeFactors(X);
	int flag = 1;
	for (int i = 0; i < N-1; i++)
	{
		cin >> X;
		if (flag) { map<int,int> pf = primeFactors(X);
		if (!bate(inic,pf)) flag = 0; }
	}
	cout << (flag?"Yes":"No") << endl;
}


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

#define mp make_pair
#define pb push_back
#define INF 1000000000

typedef long long ll;
typedef pair<int,int> pii;
const double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;

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

ll lcm(ll a, ll b)
{
	return a*b/gcd(a,b);
}

ll N, X, V[112345];
int dp[1000000];
vector<int> primes;
void sieve()
{
	for (int i = 2; i < 1000000; i++)
		dp[i] = 1;
	for (int i = 2; i < 1000000; i++)
		for (int j = 2*i; j < 1000000; j+=i)
			dp[j] = 0;
	for (int i = 2; i < 1000000; i++)
		if (dp[i]) primes.push_back(i);
}

map<int,int> primeFactors(ll N) { // remember: vi is vector<int>, ll is long long
map<int,int> factors;
ll PF_idx = 0, PF = primes[PF_idx]; // primes has been populated by sieve
while (PF * PF <= N) { // stop at sqrt(N); N can get smaller
while (N % PF == 0) { N /= PF; if (PF>3) factors[PF]++; } // remove PF
PF = primes[++PF_idx]; // only consider primes!
}
if (N != 1 && N != 2 && N != 3) factors[N]++; // special case if N is a prime
return factors; // if N does not fit in 32-bit integer and is a prime
}
bool bate(map<int,int> m1, map<int,int> m2)
{
	if (m1.size() != m2.size()) return false;
	for (auto i = m1.begin(); i != m1.end(); i++)
		if (i->second != m2[i->first])
			return false;
	return true;
}
int main()
{
	sieve();
	cin >> N >> X;
	inic = primeFactors(X);
	int flag = 1;
	for (int i = 0; i < N-1; i++)
	{
		cin >> X;
		if (flag) { map<int,int> pf = primeFactors(X);
		if (!bate(inic,pf)) flag = 0; }
	}
	cout << (flag?"Yes":"No") << endl;
}


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

#define mp make_pair
#define pb push_back
#define INF 1000000000

typedef long long ll;
typedef pair<int,int> pii;
const double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;

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

ll lcm(ll a, ll b)
{
	return a*b/gcd(a,b);
}

ll N, X, V[112345];
int dp[1000000];
vector<int> primes;
void sieve()
{
	for (int i = 2; i < 1000000; i++)
		dp[i] = 1;
	for (int i = 2; i < 1000000; i++)
		for (int j = 2*i; j < 1000000; j+=i)
			dp[j] = 0;
	for (int i = 2; i < 1000000; i++)
		if (dp[i]) primes.push_back(i);
}

map<int,int> inic;
int flag;
map<int,int> primeFactor(ll N) { // remember: vi is vector<int>, ll is long long
map<int,int> factors;
ll PF_idx = 0, PF = primes[PF_idx]; // primes has been populated by sieve
while (PF * PF <= N) { // stop at sqrt(N); N can get smaller
while (N % PF == 0) { N /= PF; if (PF>3) factors[PF]++; } // remove PF
PF = primes[++PF_idx]; // only consider primes!
}
if (N != 1 && N != 2 && N != 3) factors[N]++; // special case if N is a prime
return factors; // if N does not fit in 32-bit integer and is a prime
}
ll primeFactors(ll N) { // remember: vi is vector<int>, ll is long long
map<int,int> factors;
ll cnt = 0;
ll PF_idx = 0, PF = primes[PF_idx]; // primes has been populated by sieve
while (PF * PF <= N) { // stop at sqrt(N); N can get smaller
while (N % PF == 0) { N /= PF; if (PF>3) factors[PF]++; if (inic.find(PF) != inic.end() && factors[PF] == inic[PF]) cnt++; if(inic.find(PF) != inic.end() && factors[PF] > inic[PF]) cnt--; } // remove PF
PF = primes[++PF_idx]; // only consider primes!
}
if (N != 1 && N != 2 && N != 3) factors[N]++; // special case if N is a prime
return cnt; // if N does not fit in 32-bit integer and is a prime
}
bool bate(map<int,int> m1, map<int,int> m2)
{
	if (m1.size() != m2.size()) return false;
	for (auto i = m1.begin(); i != m1.end(); i++)
		if (i->second != m2[i->first])
			return false;
	return true;
}
int main()
{
	sieve();
	cin >> N >> X;
	inic = primeFactor(X);
	flag = 1;
	//for (auto i : inic) cout << i.first << endl;
	for (int i = 0; i < N-1; i++)
	{
		cin >> X;

		if (flag) if (primeFactors(X) != inic.size()) { flag = 0;}

	}
	cout << (flag?"Yes":"No") << endl;
}


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

#define mp make_pair
#define pb push_back
#define INF 1000000000

typedef long long ll;
typedef pair<int,int> pii;
const double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;

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

ll lcm(ll a, ll b)
{
	return a*b/gcd(a,b);
}

ll N, X, V[112345];
int dp[1000000];
vector<int> primes;
void sieve()
{
	for (int i = 2; i < 1000000; i++)
		dp[i] = 1;
	for (int i = 2; i < 1000000; i++)
		for (int j = 2*i; j < 1000000; j+=i)
			dp[j] = 0;
	for (int i = 2; i < 1000000; i++)
		if (dp[i]) primes.push_back(i);
}

map<int,int> primeFactors(ll N) { // remember: vi is vector<int>, ll is long long
map<int,int> factors;
ll PF_idx = 0, PF = primes[PF_idx]; // primes has been populated by sieve
while (PF * PF <= N) { // stop at sqrt(N); N can get smaller
while (N % PF == 0) { N /= PF; if (PF>3) factors[PF]++; } // remove PF
PF = primes[++PF_idx]; // only consider primes!
}
if (N != 1 && N != 2 && N != 3) factors[N]++; // special case if N is a prime
return factors; // if N does not fit in 32-bit integer and is a prime
}
bool bate(map<int,int> m1, map<int,int> m2)
{
	if (m1.size() != m2.size()) return false;
	for (auto i = m1.begin(); i != m1.end(); i++)
		if (i->second != m2[i->first])
			return false;
	return true;
}
int main()
{
	sieve();
	cin >> N >> X;
	inic = primeFactors(X);
	int flag = 1;
	for (int i = 0; i < N-1; i++)
	{
		cin >> X;
		if (flag && N < 2000) { map<int,int> pf = primeFactors(X);
		if (!bate(inic,pf)) flag = 0; }
	}
	cout << (flag?"Yes":"No") << endl;
}


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

#define mp make_pair
#define pb push_back
#define INF 1000000000

typedef long long ll;
typedef pair<int,int> pii;
const double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;

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

ll lcm(ll a, ll b)
{
	return a*b/gcd(a,b);
}

ll N, X, V[112345];
int dp[1000000];
vector<int> primes;
void sieve()
{
	for (int i = 2; i < 1000000; i++)
		dp[i] = 1;
	for (int i = 2; i < 1000000; i++)
		for (int j = 2*i; j < 1000000; j+=i)
			dp[j] = 0;
	for (int i = 2; i < 1000000; i++)
		if (dp[i]) primes.push_back(i);
}

map<int,int> primeFactors(ll N) { // remember: vi is vector<int>, ll is long long
map<int,int> factors;
ll PF_idx = 0, PF = primes[PF_idx]; // primes has been populated by sieve
while (PF * PF <= N) { // stop at sqrt(N); N can get smaller
while (N % PF == 0) { N /= PF; if (PF>3) factors[PF]++; } // remove PF
PF = primes[++PF_idx]; // only consider primes!
}
if (N != 1 && N != 2 && N != 3) factors[N]++; // special case if N is a prime
return factors; // if N does not fit in 32-bit integer and is a prime
}
bool bate(map<int,int> m1, map<int,int> m2)
{
	for (auto i = m1.begin(); i != m1.end(); i++)
		if (i->second != m2[i->first])
			return false;
	for (auto i = m2.begin(); i != m2.end(); i++)
		if (i->second != m1[i->first])
			return false;
	return true;
}
int main()
{
	sieve();
	cin >> N >> X;
	map<int,int> inic = primeFactors(X);
	int flag = 1;
	for (int i = 0; i < N-1; i++)
	{
		cin >> X;
		map<int,int> pf = primeFactors(X);
		if (!bate(inic,pf)) { flag = 0; break; }
	}
	cout << (flag?"Yes":"No") << endl;
}


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

#define mp make_pair
#define pb push_back
#define INF 1000000000

typedef long long ll;
typedef pair<int,int> pii;
const double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;

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

ll lcm(ll a, ll b)
{
	return a*b/gcd(a,b);
}

int dp[1000000];
vector<int> primes;
void sieve()
{
	for (int i = 2; i < 1000000; i++)
		dp[i] = 1;
	for (int i = 2; i < 1000000; i++)
		for (int j = 2*i; j < 1000000; j+=i)
			dp[j] = 0;
	for (int i = 2; i < 1000000; i++)
		if (dp[i]) primes.push_back(i);
}

bool bate(ll N) { // remember: vi is vector<int>, ll is long long
map<int,int> factors;
ll PF_idx = 0, PF = primes[PF_idx]; // primes has been populated by sieve
while (PF * PF <= N) { // stop at sqrt(N); N can get smaller
while (N % PF == 0) { N /= PF; if (PF>3) return false; } // remove PF
PF = primes[++PF_idx]; // only consider primes!
}
if (N != 1 && N != 2 && N != 3) return false; // special case if N is a prime
return true; // if N does not fit in 32-bit integer and is a prime
}

int main()
{
	int N, V[112345];
	sieve();
	cin >> N;
	for (int i = 0; i < N; i++) cin >> V[i];
	sort(V,V+N);
	int maior = V[N-1];
	for (int i = N-2; i >= 0; i--)
	{
		if (maior%V[i]!=0 && !bate(lcm(maior,V[i])) || maior%V[i]==0 && !bate(maior/V[i]))
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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

#define mp make_pair
#define pb push_back
#define INF 1000000000

typedef long long ll;
typedef pair<int,int> pii;
const double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;

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

ll lcm(ll a, ll b)
{
	return a*b/gcd(a,b);
}

ll N, X, V[112345];
int dp[1000000];
vector<int> primes;
void sieve()
{
	for (int i = 2; i < 1000000; i++)
		dp[i] = 1;
	for (int i = 2; i < 100000; i++)
		for (int j = 2*i; j < 1000000; j+=i)
			dp[j] = 0;
	for (int i = 2; i < 1000000; i++)
		if (dp[i]) primes.push_back(i);
}

map<int,int> primeFactors(ll N) { // remember: vi is vector<int>, ll is long long
map<int,int> factors;
ll PF_idx = 0, PF = primes[PF_idx]; // primes has been populated by sieve
while (PF * PF <= N) { // stop at sqrt(N); N can get smaller
while (N % PF == 0) { N /= PF; if (PF>3) factors[PF]++; } // remove PF
PF = primes[++PF_idx]; // only consider primes!
}
if (N != 1 && N != 2 && N != 3) factors[N]++; // special case if N is a prime
return factors; // if N does not fit in 32-bit integer and is a prime
}
bool bate(map<int,int> m1, map<int,int> m2)
{
	for (auto i = m1.begin(); i != m1.end(); i++)
		if (i->second != m2[i->first])
			return false;
	return true;
}
int main()
{
	sieve();
	cin >> N >> X;
	map<int,int> inic = primeFactors(X);
	int flag = 1;
	for (int i = 0; i < N-1; i++)
	{
		cin >> X;
		map<int,int> pf = primeFactors(X);
		if (!bate(inic,pf)) flag = 0;
	}
	cout << (flag?"Yes":"No") << endl;
}