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

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


-----Input-----

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

The second line contains n integer numbers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9) — the bids of players.


-----Output-----

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


-----Examples-----
Input
4
75 150 75 50

Output
Yes

Input
3
100 150 250

Output
No



-----Note-----

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

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

Difficulty: competition

Starter code:

Solutions:
def i23(x):
    while x%2==0:
        x//=2
    while x%3==0:
        x//=3
    return x == 1
import fractions
from fractions import gcd
x = int(input())
y = list(map(int, input().split(' ')))

gcdx = y[0]
for i in y:
    gcdx = gcd(i, gcdx)

for i in y:
    if not i23(i/gcdx):
        print("No")
        quit()
print("Yes")


def solve(N, As):
    core = find_core(As[0])
    for a in As[1:]:
        core_a = find_core(a)
        if core != core_a:
            return False
    return True

def find_core(a):
    while a % 2 == 0:
        a //= 2
    while a % 3 == 0:
        a //= 3
    return a

N = int(input())
As = list(map(int, input().split()))
if solve(N, As):
    print('Yes')
else:
    print('No')


input()

def gcd(a,b):
    x,y = a,b
    while x:
        x, y = y % x, x
    return y

numbers = list(map(int, input().split()))

div = numbers[0]
for x in numbers:
    div = gcd(div, x)

for x in numbers:
    x = x / div
    while x % 3 == 0:
        x = x / 3
    while x % 2 == 0:
        x = x / 2
    if x != 1:
        print("No")
        return

print("Yes")


def check(x):
    while (x>1):
        if (x%2==0):
            x/=2
        elif (x%3==0):
            x/=3
        else:
            return False
    return True

a=[]
n=int(input())
a=list(map(int,input().split()))
a.sort()
flag=True
while (a[0]%2==0 or a[0]%3==0):
    if(a[0]%2==0):
        a[0]/=2
    else:
        a[0]/=3
#print (a)
for x in a:
    y=x%a[0]
    z=x/a[0]
    #print (y,z)
    if(y==0 and check(z)):
        continue
    else:
        flag=False
if flag==True:
    print ('Yes')
else:
    print ('No')

amount = int(input())
bet = map(int, input().split())
bet_list = list(bet)
for i in range(0, amount):
    while bet_list[i]%2==0:
        bet_list[i]//=2
    while bet_list[i]%3==0:
        bet_list[i]//=3
bet_list.sort()
if bet_list[0] == bet_list[-1]:
    print('Yes')
else:
    print('No')

amount = int(input()) #количество ставок
bet = map(int, input().split())
bet_list = list(bet) # преобразование в список
for i in range(0, amount):
    while bet_list[i]%2==0:
        bet_list[i]/=2
    while bet_list[i]%3==0:
        bet_list[i]/=3
bet_list.sort()
if bet_list[0] == bet_list[-1]:
    print('Yes')
else:
    print('No')

amount = int(input()) #количество ставок
bet = map(int, input().split())
bet_list = list(bet) # преобразование в список
for i in range(0, amount):
    while bet_list[i]%2==0:
        bet_list[i]/=2
    while bet_list[i]%3==0:
        bet_list[i]/=3
bet_list.sort()
if max(bet_list) == min(bet_list):
    print('Yes')
else:
    print('No')

def gcd(a,b):
	while(b!=0):
		r = a%b
		a = b
		b = r
	return a
def valid(m,n):
	g = gcd(m,n)
	x = m//g
	y = n//g
	do1 = 0	
	tr1 = 0
	do2 = 0 
	tr2 = 0
	while(x%2==0):
		x/=2
		do1+=1
	while(x%3==0):
		x/=3
		tr1+=1

	while(y%2==0):
		y/=2
		do2+=1
	while(y%3==0):
		y/=3
		tr2+=1
		
	if(x>1 or y>1):
		return -1
	return g*pow(2,max(do1,do2))*pow(3,max(tr1,tr2))
N = int(input())
A = list(int(i) for i in input().split())
prev = -1
answered = False
for i in range(N):
	if(prev==-1):
		prev = A[i]
		continue
	m = max(A[i],prev)
	n = min(A[i],prev)
	prev = valid(m,n)
	if(prev==-1):
		print ("No")
		answered = True
		break
if(not answered):
	print("Yes")


n = input()
Li = input()
ar = map(int, Li.split())
res = -1
fl = 1
for i in ar:
    while i%2 == 0:
        i = i/2
    while i%3 == 0:
        i = i/3
    if res == -1:
        res = i
    elif res != i:
        fl = 0
if fl == 1:
    print ("Yes\n")
else:
    print ("No\n")

from functools import reduce
g=lambda a,b:g(b,a%b)if b else a
gcd=lambda x:reduce(g,x)
input()
*a,=list(map(int,input().split()))
b=gcd(a)
a=[i//b for i in a]
c=True
for i in a:
    while not i%2:i//=2
    while not i%3:i//=3
    if i!=1:
        c=False
        print('No')
        break
if c:print('Yes')


n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
	while a[i] % 2 == 0:
		a[i] /= 2
	while a[i] % 3 == 0:
		a[i] /= 3
print('Yes' if all(x == a[0] for x in a) else 'No')


n=int(input())
l=input().split()
for i in range(n):
    l[i]=int(l[i])
    while(l[i]%2==0):
        l[i]/=2
    while(l[i]%3==0):
        l[i]/=3
flag=1
for i in range(n):
    if(l[i]!=l[0]):
        print("No")
        flag=0
        break
if(flag):
    print("Yes")


__author__ = '$'
import sys


def GCD (x, y):
    return x if y == 0 else GCD(y, x % y)
try:
    while True:
        n = int(input())
        val = list(map(int, input().split(" ")))
        res = val[0]
        for i in range(n-1):
            res = GCD(res, val[i+1])
        ans = True
        for i in range(n):
            tmp = val[i] // res
            while tmp != 1:
                if tmp % 2 == 0:
                    tmp //= 2
                elif tmp % 3 == 0:
                    tmp //= 3
                else:
                    ans = False
                    break
            if not ans:
                break
        print("Yes" if ans else "No")
except EOFError:
    pass

def div23(a):
	while (a % 2 == 0):
		a //= 2
	while (a % 3 == 0):
		a //= 3
	return a

n = int(input())
s = [int(i) for i in input().split(' ')]
a = div23(s[0])
i = 1
while i < len(s):
	if (a != div23(s[i])):
		break
	i += 1

if i == len(s):
	print("Yes")
else:
	print("No")


__author__ = 'pxy'
n=int(input())
c=[int(i) for i in input().split()]
for j in range(n):
    while c[j] % 2 == 0:
        c[j]=c[j]// 2
    while c[j] % 3 == 0:
        c[j]=c[j]// 3
f=True
for j in range(n-1):
    if(c[j]!=c[j+1]):

        f=False
        break
if f:
    print('Yes')
else:
    print('No')

__author__ = 'pxy'
n=int(input())
c=[int(i) for i in input().split()]
f=True
for j in range(n):
    while c[j] % 2 == 0:
        c[j]=c[j]// 2
    while c[j] % 3 == 0:
        c[j]=c[j]// 3
    if j>=1:
        if(c[j]!=c[j-1]):
            f=False
            break

if f:
    print('Yes')
else:
    print('No')

__author__ = 'pxy'
n=int(input())
c=[int(i) for i in input().split()]
f=True
for j in range(n):
    while c[j] % 2 == 0:
        c[j]=c[j]// 2
    while c[j] % 3 == 0:
        c[j]=c[j]// 3
if(max(c)==min(c)):
    print('Yes')
else:
    print('No')

n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])

def thanhloc(x):     #loai bo het factor 2 va 3
    while (x % 2 == 0):
        x = x //2
    while (x % 3 == 0):
        x = x //3
    return(x)

res = 'Yes'
a[0] = thanhloc(a[0])
#import pdb; pdb.set_trace()
for i in range(1,n):
    a[i] = thanhloc(a[i])
    if a[i] != a[i-1] :
        res = 'No'
        break

print(res)


n = int(input())
a = [int(i) for i in input().split()]
for i in range (n):
    while a[i] % 2 == 0:
        a[i] = a[i]// 2
    while a[i] % 3 == 0:
        a[i] = a[i]// 3
r = 0;
for i in range (n-1):
     if a[i] != a[i+1]:
        r = 1;
if r:
    print('No')
else:
    print ('Yes')
    


def main():
    input()
    l = list(map(int, input().split()))
    a = l[-1]
    while not a % 2:
        a //= 2
    while not a % 3:
        a //= 3
    for x in l:
        while not x % 2:
            x //= 2
        while not x % 3:
            x //= 3
        if x != a:
            print("No")
            return
    print("Yes")


def __starting_point():
    main()

__starting_point()

def main():
    input()
    l = list(map(int, set(input().split())))
    a = l[-1]
    while not a % 2:
        a //= 2
    while not a % 3:
        a //= 3
    for x in l:
        while not x % 2:
            x //= 2
        while not x % 3:
            x //= 3
        if x != a:
            print("No")
            return
    print("Yes")


def __starting_point():
    main()

__starting_point()