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: EASY
Tags: Mathematics

Number theory

Implementation

Starter code:

Solutions:
n = int(input())
arr = list(map(int, input().split()))
l = []
for i in arr:
	x = i
	while x % 2 == 0:
		x /= 2
	while x % 3 == 0:
		x /= 3
	l.append(x)
if len(set(l)) == 1:
	print('Yes')
else:
	print('No')


n = int(input())

def f(x):
	x = int(x)
	for i in (2, 3):
		while x > 0 and x % i == 0:
			x //= i
	return x
s = set(map(f, input().split()))
print('Yes' if len(s) == 1 else 'No')


import math
n = int(input())
a = list(set(map(int, input().split())))
lcm = a[0]
f1 = 0
while lcm % 2 == 0:
	lcm /= 2
while lcm % 3 == 0:
	lcm /= 3
for i in a[1:]:
	while i % 2 == 0:
		i /= 2
	while i % 3 == 0:
		i /= 3
	if i != lcm:
		f1 = 1
		break
if f1:
	print('NO')
else:
	print('YES')


from sys import stdin, stdout

def norm(x):
	while x % 2 == 0:
		x /= 2
	while x % 3 == 0:
		x /= 3
	return x
ls = stdin.readlines()
xs = [norm(int(x)) for x in ls[1].split()]
if all((x == xs[0] for x in xs[1:])):
	stdout.write('Yes\n')
else:
	stdout.write('No\n')


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')


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, log, floor, ceil
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, lst):
	gcdAns = lst[0]
	for i in range(1, n):
		gcdAns = gcd(gcdAns, lst[i])
	for i in range(n):
		lst[i] //= gcdAns
	for i in lst:
		val = i
		val /= val & ~(val - 1)
		if abs(floor(log(val, 3)) - log(val, 3)) > 10 ** (-7) and abs(ceil(log(val, 3)) - log(val, 3)) > 10 ** (-7):
			return 'No'
	return 'Yes'
n = int(input())
lst = list(map(int, input().split()))
print(solve(n, lst))


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')


n = int(input())
l = list(map(int, input().split()))
g = 0
v = 0
c = 'YES'
for i in range(n):
	g = l[i]
	while g % 2 == 0 or g % 3 == 0:
		if g % 2 == 0:
			g = g // 2
		if g % 3 == 0:
			g = g // 3
	if v != 0 and g != v:
		c = 'NO'
		break
	elif v == 0:
		v = g
print(c)


n = int(input())
a = list(map(int, input().split()))
b = 0
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
	if b == 0:
		b = a[i]
	if a[i] != b:
		print('NO')
		exit()
print('YES')


n = int(input())
prev = -1
for x in input().split():
	temp = int(x)
	while temp % 2 == 0:
		temp = temp // 2
	while temp % 3 == 0:
		temp = temp // 3
	if prev != -1:
		if temp != prev:
			print('No')
			break
	else:
		prev = temp
else:
	print('Yes')


n = int(input())
lis = list(map(int, input().split()))
ans = [0] * n
ans[0] = 1 * lis[0]
while ans[0] % 2 == 0:
	ans[0] = ans[0] // 2
while ans[0] % 3 == 0:
	ans[0] = ans[0] // 3
for i in range(1, n):
	ans[i] = lis[i] * 1
	while ans[i] % 2 == 0:
		ans[i] = ans[i] // 2
	while ans[i] % 3 == 0:
		ans[i] = ans[i] // 3
	if ans[i] != ans[i - 1]:
		print('No')
		break
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')
main()


x = int(input())
a = input().split()
for u in range(x):
	i = int(a[u])
	while i % 3 == 0:
		i = int(i / 3)
	while i % 2 == 0:
		i = int(i / 2)
	a[u] = i
tt = a[0]
c = 0
for y in a:
	if y == tt:
		c = c + 1
if c == x:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
m = a[0]
while m % 2 == 0:
	m //= 2
while m % 3 == 0:
	m //= 3
i = 1
flag = True
while i < n and flag:
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
	if a[i] == m:
		i += 1
	else:
		flag = False
if flag:
	print('Yes')
else:
	print('No')


def solve(n, a):
	b = set()
	for i in a:
		while i % 2 == 0:
			i = i // 2
		while i % 3 == 0:
			i = i // 3
		b.add(i)
	return 'Yes' if len(b) == 1 else 'No'

def main(infile, outfile):
	n = int(infile.readline())
	a = list(map(int, infile.readline().split()))
	outfile.write(str(solve(n, a)) + '\n')
from sys import stdin, stdout
main(stdin, stdout)


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 = list(map(int, input().split()))
for i in range(n):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
k = 0
for i in range(n):
	if a[i] != a[0]:
		print('NO')
		k = 0
		break
	else:
		k = 1
if k == 1:
	print('YES')


def main(n, a):
	for i in range(n):
		while a[i] % 3 == 0 or a[i] % 2 == 0:
			if a[i] % 3 == 0:
				a[i] //= 3
			if a[i] % 2 == 0:
				a[i] //= 2
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			return 'No'
	return 'Yes'
print(main(int(input()), list(map(int, input().split(' ')))))


from math import gcd
nb = int(input())
liste2 = []
liste = [int(x) for x in input().split()]

def pp():
	for loop in range(len(liste)):
		while liste[loop] % 2 == 0:
			liste[loop] //= 2
		while liste[loop] % 3 == 0:
			liste[loop] //= 3
		liste2.append(liste[loop])
	if liste2.count(liste2[0]) == len(liste2):
		return 'Yes'
	return 'No'
print(pp())


import math as m
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	if i == 0:
		gcd = a[i]
	else:
		gcd = m.gcd(gcd, a[i])
f = 0
for i in range(n):
	if f:
		break
	m = a[i] // gcd
	while m != 1:
		if m % 2 == 0:
			m //= 2
		elif m % 3 == 0:
			m //= 3
		else:
			f = 1
			break
if f:
	print('No')
else:
	print('Yes')


from collections import Counter
import string
import bisect
import math
import sys
from fractions import Fraction

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))

def lcm(a, b):
	return a * b // math.gcd(a, b)
testcases = 1
for _ in range(testcases):
	n = vary(1)
	num = array_int()
	lc = 1
	for i in range(n):
		while num[i] % 2 == 0:
			num[i] //= 2
		while num[i] % 3 == 0:
			num[i] //= 3
	if len(set(num)) == 1:
		print('Yes')
	else:
		print('No')


n = int(input())
l = list(map(int, input().split()))
flag = 0
cnt = 0
for i in range(n):
	while l[i] % 2 == 0:
		l[i] = l[i] // 2
	while l[i] % 3 == 0:
		l[i] = l[i] // 3
	if l[i] != flag:
		cnt += 1
		flag = l[i]
if cnt == 1:
	print('YES')
else:
	print('NO')


from math import gcd
n = int(input())
a = list(map(int, input().split()))
b = a[0]
for i in a:
	b = gcd(b, i)
for i in a:
	z = i // b
	if z > 1:
		while z > 1:
			if z % 2 == 0:
				z //= 2
			elif z % 3 == 0:
				z //= 3
			else:
				n = -1
				break
if n == -1:
	print('NO')
else:
	print('YES')


import sys
n = int(input())
a = list(map(int, input().split()))
while a[0] % 2 == 0:
	a[0] = a[0] // 2
while a[0] % 3 == 0:
	a[0] = a[0] // 3
for i in range(1, n):
	while a[i] % 2 == 0:
		a[i] = a[i] // 2
	while a[i] % 3 == 0:
		a[i] = a[i] // 3
	if a[i] != a[i - 1]:
		print('No')
		sys.exit()
print('Yes')


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


from math import gcd
from functools import reduce
n = int(input())
l = list(map(int, input().split()))
x = reduce(lambda x, y: gcd(x, y), l)
A = 'YES'
for i in range(n):
	a = l[i] // x
	for p in (2, 3):
		while a % p == 0:
			a //= p
	if a != 1:
		A = 'NO'
		break
print(A)


def super(x):
	while x % 2 == 0:
		x /= 2
	while x % 3 == 0:
		x /= 3
	return x
n = int(input())
a = list(map(int, input().split()))
eq = super(a[0])
for i in range(1, n):
	if super(a[i]) != eq:
		eq = 0
print('Yes' if eq else 'No')


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
if min(a) == max(a):
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(x) for x in input().split()]
v = set()
for e in a:
	while e % 2 == 0:
		e = e // 2
	while e % 3 == 0:
		e = e // 3
	v.add(e)
if len(v) == 1:
	print('Yes')
else:
	print('No')


import math
n = int(input())
A = list(map(int, input().split()))
x = math.gcd(A[0], A[1])
for i in range(2, n):
	x = math.gcd(x, A[i])
count = 0
for i in range(n):
	A[i] = A[i] // x
	while A[i] % 2 == 0:
		A[i] = A[i] // 2
	while A[i] % 3 == 0:
		A[i] = A[i] // 3
	if A[i] != 1:
		count = 1
		break
if count == 0:
	print('Yes')
else:
	print('No')


import sys
input = sys.stdin.readline

def inInt():
	return int(input())

def inStr():
	return input().strip('\n')

def inIList():
	return list(map(int, input().split()))

def inSList():
	return input().split()

def YesNo(ans):
	print('Yes' if ans else 'No')

def solve(a, n):
	for i in range(n):
		while True:
			if a[i] % 2 == 0:
				a[i] /= 2
			elif a[i] % 3 == 0:
				a[i] /= 3
			else:
				break
	YesNo(max(a) == min(a))
n = inInt()
a = inIList()
solve(a, n)


import sys
import math
import itertools
import collections

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return '\n'.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
n = ii()
a = li()
s = set()
for i in range(n):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
	s.add(a[i])
print('Yes') if len(s) == 1 else print('No')


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

def thanhloc(x):
	while x % 2 == 0:
		x = x // 2
	while x % 3 == 0:
		x = x // 3
	return x
res = 'Yes'
a[0] = thanhloc(a[0])
for i in range(1, n):
	a[i] = thanhloc(a[i])
	if a[i] != a[i - 1]:
		res = 'No'
		break
print(res)


from math import gcd
n = int(input())
li = list(map(int, input().split()))
x = int(0)
for i in li:
	x = gcd(i, x)
for i in range(len(li)):
	li[i] = li[i] // x
for i in range(len(li)):
	while li[i] % 2 == 0:
		li[i] = li[i] // 2
	while li[i] % 3 == 0:
		li[i] = li[i] // 3
if sum(li) == len(li):
	print('Yes')
else:
	print('No')


n = int(input())
m = list(map(int, input().split()))
for i in range(n):
	while m[i] % 2 == 0:
		m[i] //= 2
	while m[i] % 3 == 0:
		m[i] //= 3
print('YES' if len(set(m)) == 1 else 'NO')


def main():
	n = int(input())
	r = lambda : map(int, input().split())
	l = list(r())
	a = l[0]
	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')
main()


n = int(input())
nums = list(map(int, input().split()))
for (i, a) in enumerate(nums):
	while not a % 2:
		a = a // 2
	while not a % 3:
		a = a // 3
	if not i:
		res = a
	if res != a:
		print('No')
		exit()
print('Yes')


from math import *
from collections import *
from random import *
from bisect import *
import sys

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())

def inp():
	return int(input())
n = inp()
a = lis()
x = 0
for i in a:
	x = gcd(i, x)
for i in range(n):
	a[i] = a[i] // x
fl = 0
s = 'Yes'
for i in a:
	j = i
	while j % 2 == 0:
		j = j // 2
	while j % 3 == 0:
		j = j // 3
	if j != 1:
		fl = 1
		break
if fl:
	s = 'No'
print(s)


n = int(input())
a = list(map(int, input().split()))
res = 'Yes'
for i in range(n):
	while a[i] % 3 == 0:
		a[i] //= 3
	while a[i] % 2 == 0:
		a[i] //= 2
	if i > 0 and a[i] != a[i - 1]:
		res = 'No'
		break
print(res)


import sys
import math
import collections
import bisect

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	n = int(input())
	arr = get_list()
	for i in range(n):
		while arr[i] % 2 == 0:
			arr[i] = arr[i] // 2
		while arr[i] % 3 == 0:
			arr[i] = arr[i] // 3
	if len(set(arr)) == 1:
		print('Yes')
	else:
		print('No')


from fractions import gcd
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
g = reduce(gcd, a)

def f(x):
	while x % 2 == 0:
		x //= 2
	while x % 3 == 0:
		x //= 3
	return x == 1
print('Yes' if all((f(t // g) for t in a)) else 'No')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
n = ii()
arr = li()
gcdx = arr[0]
for i in range(1, n):
	gcdx = math.gcd(gcdx, arr[i])
for i in arr:
	i = i // gcdx
	while i % 2 == 0:
		i //= 2
	while i % 3 == 0:
		i //= 3
	if i != 1:
		print('NO')
		exit()
print('YES')


import sys
for _ in range(1):
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(n):
		while l[i] % 2 == 0:
			l[i] //= 2
		while l[i] % 3 == 0:
			l[i] //= 3
	if len(set(l)) == 1:
		print('Yes')
	else:
		print('No')


N = input().split()
A = list(map(int, input().split()))

def reduce(N):
	if N % 2 == 0:
		return reduce(N / 2)
	if N % 3 == 0:
		return reduce(N / 3)
	return N
if len(set((reduce(a) for a in A))) == 1:
	print('Yes')
else:
	print('No')


import fractions
N = int(input())
A = list(map(int, input().split()))
for i in range(1, N):
	gcd = fractions.gcd(A[0], A[i])
	diva = A[0] // gcd
	divb = A[i] // gcd
	while diva % 2 == 0:
		diva //= 2
	while divb % 2 == 0:
		divb //= 2
	while diva % 3 == 0:
		diva //= 3
	while divb % 3 == 0:
		divb //= 3
	if diva >= 2 or divb >= 2:
		print('No')
		exit()
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')


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


def f(n):
	while n % 3 == 0:
		n //= 3
	while n % 2 == 0:
		n //= 2
	return n
n = int(input())
ar = list(map(int, input().split()))
for x in range(n):
	ar[x] = f(ar[x])
for x in range(1, n):
	if ar[x] != ar[x - 1]:
		print('No')
		break
else:
	print('Yes')


import sys
from math import gcd
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n,) = I()
l = I()
gd = l[0]
for i in range(1, n):
	gd = gcd(gd, l[i])
pos = 0
for i in range(n):
	cr = l[i] // gd
	while cr % 2 == 0:
		cr //= 2
	while cr % 3 == 0:
		cr //= 3
	if cr != 1:
		pos = 1
		break
print('YNEOS'[pos::2])


def hello(a):
	res = sol(arr[0])
	for i in arr[1:]:
		re = sol(i)
		if re != res:
			return False
	return True

def sol(a):
	while a % 2 == 0:
		a //= 2
	while a % 3 == 0:
		a //= 3
	return a
n = int(input())
arr = list(map(int, input().split(' ')))
if hello(arr):
	print('YES')
else:
	print('NO')


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
for x in a:
	y = x % a[0]
	z = x / a[0]
	if y == 0 and check(z):
		continue
	else:
		flag = False
if flag == True:
	print('Yes')
else:
	print('No')


def gcd(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a

def gcd_list(A):
	n = len(A)
	if n == 0:
		return 1
	if n == 1:
		return A[0]
	g = gcd(A[0], A[1])
	for i in range(2, n):
		g = gcd(g, A[i])
	return g

def lcm(a, b):
	return a * b // gcd(a, b)

def lcm_list(A):
	n = len(A)
	if n == 0:
		return 1
	if n == 1:
		return A[0]
	l = lcm(A[0], A[1])
	for i in range(2, n):
		l = lcm(l, A[i])
	return l
n = int(input())
A = [int(a) for a in input().split()]
g = gcd_list(A)
flag = True
for i in range(n):
	q = A[i] // g
	while q % 2 == 0:
		q //= 2
	while q % 3 == 0:
		q //= 3
	if q != 1:
		flag = False
		break
print('Yes' if flag else 'No')


from sys import *
from math import *
input = lambda : stdin.readline()
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
n = int(input())
arr = int_arr()
mx = max(arr)
ans = float('-inf')
for i in range(n):
	while arr[i] % 2 == 0:
		arr[i] = arr[i] // 2
	while arr[i] % 3 == 0:
		arr[i] = arr[i] // 3
print('Yes' if len(set(arr)) == 1 else 'No')


n = int(input())
arr = set((int(x) for x in input().split()))
m = max(arr)
while m % 3 == 0:
	m //= 3
while m % 2 == 0:
	m //= 2
for i in arr:
	while i % 3 == 0:
		i //= 3
	while i % 2 == 0:
		i //= 2
	if i != m:
		print('No')
		exit(0)
print('Yes')


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')


n = int(input())
a = list(map(int, input().split()))
for i in range(len(a)):
	while a[i] % 2 == 0:
		a[i] = a[i] // 2
	while a[i] % 3 == 0:
		a[i] = a[i] // 3
flag = 1
for i in range(1, len(a)):
	if a[i] != a[0]:
		print('No')
		flag = 0
		break
if flag:
	print('Yes')


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
lx = lambda x: map(int, input().split(x))
from collections import Counter

def g(n):
	while n % 6 == 0:
		n //= 6
	while n % 2 == 0:
		n //= 2
	while n % 3 == 0:
		n //= 3
	return n

def f():
	n = t()
	a = sorted(set(ll()))
	a[0] = g(a[0])
	for i in a[1:]:
		x = g(i)
		if x != a[0]:
			print('NO')
			break
	else:
		print('YES')
f()


n = int(input())
k = 0
p = [int(i) for i in input().split()]
while p[0] % 2 == 0 or p[0] % 3 == 0:
	if p[0] % 2 == 0:
		p[0] = p[0] // 2
	if p[0] % 3 == 0:
		p[0] = p[0] // 3
mn = p[0]
for i in range(1, n):
	k = p[i]
	while k % 2 == 0 or k % 3 == 0:
		if k % 2 == 0:
			k = k // 2
		if k % 3 == 0:
			k = k // 3
	if k != mn:
		print('No')
		break
if i == n - 1 and mn == k:
	print('Yes')


s = input()
(*v,) = (int(x) for x in input().split())
for i in range(len(v)):
	while v[i] % 2 == 0 or v[i] % 3 == 0:
		v[i] = v[i] / 2 if v[i] % 2 == 0 else v[i] / 3
	if i > 0 and v[i] != v[i - 1]:
		print('No')
		break
else:
	print('Yes')


from math import gcd
n = int(input())
l = list(map(int, input().split()))
t = []
for x in l:
	while x % 2 == 0:
		x //= 2
	while x % 3 == 0:
		x //= 3
	t.append(x)
print('Yes' if len(set(t)) == 1 else 'No')


n = int(input())
bids = list(map(int, input().split()))
for i in range(n):
	while bids[i] % 2 == 0:
		bids[i] /= 2
	while bids[i] % 3 == 0:
		bids[i] /= 3
ok = 1
nr = bids[0]
for i in range(1, n):
	if bids[i] != nr:
		ok = 0
		break
if ok == 1:
	print('Yes')
else:
	print('No')


from sys import stdin, stdout
from collections import Counter
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math
ai = lambda : list(map(int, stdin.readline().split()))
ei = lambda : map(int, stdin.readline().split())
ip = lambda : int(stdin.readline().strip())
n = ip()
li = ai()
for i in range(n):
	while li[i] % 2 == 0:
		li[i] //= 2
	while li[i] % 3 == 0:
		li[i] //= 3
for i in range(1, n):
	if li[i] != li[0]:
		exit(print('No'))
print('Yes')


import math
n = int(input())
a = list(map(int, input().split()))
for i in range(0, n):
	while a[i] % 2 == 0:
		a[i] = a[i] // 2
	while a[i] % 3 == 0:
		a[i] = a[i] // 3
f = 1
ok = a[0]
for i in range(0, n):
	if a[i] != ok:
		f = 0
		break
if f == 1:
	print('Yes')
else:
	print('No')


def divby(m):
	for k in range(len(arr)):
		while arr[k] % m == 0:
			arr[k] /= m

def issame():
	return len(set(arr)) <= 1
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
divby(2)
divby(3)
if issame():
	print('Yes')
else:
	print('No')


from fractions import *
n = int(input())
l = list(map(int, input().split()))
d = gcd(l[0], l[1])
for i in range(2, n):
	d = gcd(d, l[i])
for x in l:
	dd = x // d
	while dd > 1:
		if dd % 2 == 0:
			dd //= 2
		elif dd % 3 == 0:
			dd //= 3
		else:
			break
	if dd > 1:
		print('No')
		break
else:
	print('Yes')


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	while a[i] % 2 == 0:
		a[i] /= 2
	while a[i] % 3 == 0:
		a[i] /= 3
done = True
for i in range(n):
	if a[i] != a[0]:
		done = False
if done:
	print('Yes')
else:
	print('No')


def pow_2(x):
	if x % 2 == 0:
		x /= 2
		return pow_2(x)
	return int(x)

def pow_3(x):
	if x % 3 == 0:
		x /= 3
		return pow_3(x)
	return int(x)
flag = True
c = int(input())
numbers = list(map(int, input().split()))
temp = pow_2(pow_3(numbers[0]))
flag = True
for i in range(c):
	if pow_2(pow_3(numbers[i])) != temp:
		print('No')
		flag = False
		break
if flag:
	print('Yes')


n = int(input())
lst = list(map(int, input().split()))
for i in range(n):
	while lst[i] % 2 == 0:
		lst[i] //= 2
	while lst[i] % 3 == 0:
		lst[i] //= 3
check = lst[0]
for i in range(n):
	if lst[i] != check:
		print('No')
		break
else:
	print('Yes')


from sys import stdin, stdout
import math
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))

def mlog(a, b):
	y = int(math.log(a, b))
	if b ** y == a:
		return y
	return y + 1

def pow(x):
	cnt = 0
	while True:
		if not x % 6:
			x //= 6
		else:
			break
	if x == 1:
		return True
	y = mlog(x, 2)
	if 2 ** y == x:
		return True
	z = mlog(x, 3)
	if 3 ** z == x:
		return True
	else:
		return False

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(n,) = mp()
a = mp()
gc = gcd(a[0], a[1])
for i in range(2, n):
	gc = gcd(gc, a[i])
for i in range(n):
	x = a[i] // gc
	if x == 1:
		continue
	elif pow(x):
		continue
	else:
		cout('No')
		break
else:
	cout('Yes')


def hcf(a, b):
	if b == 0:
		return a
	else:
		return hcf(b, a % b)
n = int(input())
l = list(map(int, input().split()))
v = l[0]
for i in range(1, n):
	d = hcf(v, l[i])
	v = d
t = []
flag = 0
for i in range(n):
	t.append(l[i] // d)
for i in range(n):
	while t[i] % 2 == 0:
		t[i] = t[i] // 2
	while t[i] % 3 == 0:
		t[i] = t[i] // 3
for i in range(n):
	if t[i] != 1:
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


def factor(n):
	while True:
		if n % 2 == 0:
			n = n // 2
		elif n % 3 == 0:
			n = n // 3
		else:
			break
	return n
n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in range(len(a)):
	b.append(factor(a[i]))
if len(list(set(b))) == 1:
	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')


n = int(input())
arr = list(map(int, input().split()))
for i in range(n):
	while arr[i] % 2 == 0:
		arr[i] //= 2
	while arr[i] % 3 == 0:
		arr[i] //= 3
print('Yes' if arr.count(arr[0]) == len(arr) else 'No')


import sys
import string
from heapq import *
from bisect import *
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from operator import *
from itertools import accumulate
inf = float('inf')
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
en = lambda x: list(enumerate(x))
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
n = ii()
arr = rr()
for i in range(n):
	while arr[i] % 2 == 0:
		arr[i] //= 2
	while arr[i] % 3 == 0:
		arr[i] //= 3
print('Yes' if len(set(arr)) == 1 else 'No')


x = int(input())
(*li,) = map(int, input().split())
li = set(li)
li1 = set()
for i in li:
	while i % 2 == 0:
		i //= 2
	while i % 3 == 0:
		i //= 3
	li1.add(i)
print('Yes' if len(li1) == 1 else 'No')


I = lambda : map(int, input().split())

def f(x):
	while not x & 1:
		x //= 2
	while x % 3 == 0:
		x //= 3
	return x

def main():
	n = int(input())
	a = list(I())
	a = list(map(f, a))
	print(('No', 'Yes')[len(set(a)) == 1])
main()


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')


import sys
n = int(input())
an = list(map(int, sys.stdin.readline().split()))
ans = True
for i in range(n):
	while an[i] % 2 == 0:
		an[i] = int(an[i] / 2)
	while an[i] % 3 == 0:
		an[i] = int(an[i] / 3)
	if i != 0 and an[i] != an[0]:
		ans = False
		break
if ans:
	print('Yes')
else:
	print('No')


n = eval(input())
l = list(map(int, input().split()))
i = 0
g = 0
while i < n:
	if l[i] % 2 == 0:
		l[i] //= 2
		i = g
	elif l[i] % 3 == 0:
		l[i] //= 3
		i = g
	else:
		i += 1
		g += 1
if l.count(l[0]) == n:
	print('Yes')
else:
	print('No')


import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
sett = set()
for x in arr:
	flag = 0
	while x > 0 and flag == 0:
		flag = 1
		if x % 3 == 0:
			flag = 0
			x //= 3
		if x % 2 == 0:
			flag = 0
			x //= 2
	sett.add(x)
	if len(sett) > 1:
		print('No')
		break
else:
	print('Yes')


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def jud(x):
	while x % 2 == 0:
		x = x // 2
	while x % 3 == 0:
		x = x // 3
	if x == 1:
		return True
	return False
n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(n - 1):
	x = gcd(x, a[i + 1])
flag = True
for i in range(n):
	if not jud(a[i] // x):
		flag = False
		break
if flag:
	print('Yes')
else:
	print('No')


players = int(input())
bids = list(map(int, input().split()))
for player in range(players):
	while bids[player] % 2 == 0:
		bids[player] //= 2
	while bids[player] % 3 == 0:
		bids[player] //= 3
print('YES' if max(bids) == min(bids) else 'NO')


def simplify(x):
	while x == int(x):
		x /= 2
	x *= 2
	while x == int(x):
		x /= 3
	x *= 3
	return x
n = int(input())
xs = list(map(int, input().split()))
x1 = simplify(xs[0])
for x in xs[1:]:
	if x1 != simplify(x):
		print('No')
		break
else:
	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')


import math

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
n = int(input())
lst = list(map(int, input().split()))
a = lst[0]
b = lst[1]
gcd = find_gcd(a, b)
for i in range(2, len(lst)):
	gcd = find_gcd(gcd, lst[i])
yo = True
for i in lst:
	j = i // gcd
	while j % 2 == 0:
		j //= 2
	while j % 3 == 0:
		j //= 3
	if j > 1:
		yo = False
if yo:
	print('Yes')
else:
	print('No')


n = int(input())
f = list(map(int, input().split()))
p = -1
for i in range(n):
	k = f[i]
	while k % 2 == 0 or k % 3 == 0:
		if k % 2 == 0:
			k //= 2
		else:
			k //= 3
	if p == -1:
		p = k
	elif k != p:
		print('No')
		break
else:
	print('Yes')


def div23(n):
	if n == 1:
		return 1
	while n % 2 == 0:
		n /= 2
	while n % 3 == 0:
		n /= 3
	return n
n = int(input())
a = list(map(int, input().split()))
for q in range(n):
	a[q] = div23(a[q])
if a == [min(a)] * n:
	print('Yes')
else:
	print('No')


from math import gcd

def gcdd(a):
	c = 0
	for i in range(len(a)):
		c = gcd(c, a[i])
	return c
n = int(input())
a = [int(i) for i in input().split()]
val = gcdd(a)
ans = []
for i in range(n):
	ans.append(a[i] // val)
for i in range(n):
	while ans[i] % 2 == 0:
		ans[i] >>= 1
	while ans[i] % 3 == 0:
		ans[i] //= 3
for i in range(n):
	if ans[i] != 1:
		print('No')
		exit(0)
print('Yes')


from collections import Counter, defaultdict, deque
import heapq as hq
from itertools import count, islice
import math
import sys
input = sys.stdin.readline
n = int(input())
arr = [int(x) for x in input().split()]
for i in range(n):
	while arr[i] % 3 == 0:
		arr[i] //= 3
	while arr[i] % 2 == 0:
		arr[i] //= 2
q = arr[0]
for i in range(1, n):
	if arr[i] != q:
		print('No')
		exit()
print('Yes')


from sys import stdin
from math import sqrt
from collections import defaultdict

def prime_factors(n):
	out = defaultdict(lambda : 0)
	while n % 2 == 0:
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			if i != 3:
				out[i] += 1
			n = n // i
	if n > 3:
		out[n] += 1
	return out

def solve(n, arr):
	factors = prime_factors(arr[0])
	for i in range(1, len(arr)):
		if prime_factors(arr[i]) != factors:
			print('No')
			return
	print('Yes')
n = int(stdin.readline())
arr = list(set(map(int, stdin.readline().rstrip().split())))
solve(n, arr)


import math
x = int(input())
a = list(map(int, input().split()))
p = 0
f = 0
for i in a:
	while i % 2 == 0:
		i //= 2
	while i % 3 == 0:
		i //= 3
	if p == 0:
		p = i
	elif i != p:
		f = 1
		break
if f == 0:
	print('YES')
else:
	print('NO')


num_players = int(input())
bids = list(map(int, input().split(' ')))
for i in range(0, len(bids)):
	while bids[i] % 2 == 0:
		bids[i] = bids[i] / 2
	while bids[i] % 3 == 0:
		bids[i] = bids[i] / 3
flag = 0
for i in range(0, len(bids)):
	if bids[0] != bids[i]:
		print('No')
		flag = 1
		break
if flag == 0:
	print('Yes')


def sieve_erat(n):
	if n < 2:
		return []
	A = [True] * (n + 1)
	A[0] = False
	A[1] = False
	for i in range(2, int(n ** 0.5) + 1):
		if A[i]:
			j = i ** 2
			while j <= n:
				A[j] = False
				j += i
	return [i for i in range(2, n + 1) if A[i]]

def remove_two_three(x):
	while x % 2 == 0:
		x //= 2
	while x % 3 == 0:
		x //= 3
	return x
n = int(input())
arr = list(map(int, input().split()))
x = remove_two_three(arr[0])
good = True
for i in range(1, n):
	if x != remove_two_three(arr[i]):
		print('No')
		good = False
		break
if good:
	print('Yes')


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


from math import gcd
from sys import exit

def lcm(a):
	r = a[0]
	for i in a:
		r = gcd(r, i)
	return r

def check(n):
	while n % 2 == 0:
		n //= 2
	while n % 3 == 0:
		n //= 3
	return n == 1
try:
	n = int(input())
	a = list(map(int, input().split()))
	n = len(a)
	l = lcm(a)
	for i in a:
		curr = i // l
		if not check(curr):
			print('No')
			exit(0)
	print('Yes')
except Exception as e:
	print(e)


n = int(input())
a = []
for x in input().split():
	bid = int(x)
	while bid % 2 == 0:
		bid /= 2
	while bid % 3 == 0:
		bid /= 3
	a.append(bid)
val = a[0]
jackpot = True
for i in range(1, n):
	if a[i] != val:
		jackpot = False
		break
if jackpot:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
rest = a[0]
while rest % 2 == 0 or rest % 3 == 0:
	if rest % 2 == 0:
		rest //= 2
	else:
		rest //= 3
for i in a[1:]:
	if i % rest != 0:
		print('No')
		exit()
	else:
		current = i // rest
		while current % 2 == 0 or current % 3 == 0:
			if current % 2 == 0:
				current //= 2
			else:
				current //= 3
		if current != 1:
			print('No')
			exit()
print('Yes')


import math

def function(n, nums):
	for i in range(n):
		while nums[i] % 2 == 0:
			nums[i] /= 2
		while nums[i] % 3 == 0:
			nums[i] /= 3
	if len(set(nums)) == 1:
		return 'Yes'
	if len(set(nums)) != 1:
		return 'No'
n = int(input())
nums = list(map(int, input().rstrip().split()))
print(function(n, nums))


input()

def f(x):
	while x % 2 == 0:
		x /= 2
	while x % 3 == 0:
		x /= 3
	return x
a = [f(x) for x in map(int, input().split())]
print('Yes' if max(a) == min(a) else 'No')


def divide(n):
	while True:
		if n % 2 == 0:
			n //= 2
		elif n % 3 == 0:
			n //= 3
		else:
			break
	return n
n = int(input())
l = [int(i) for i in input().split()]
itJustWorks = True
rem = divide(l[0])
for i in range(1, n):
	if rem != divide(l[i]):
		itJustWorks = False
		break
print('Yes') if itJustWorks else print('No')


from sys import stdin, stdout
n = int(stdin.readline().rstrip())
(st, sh) = (list(map(int, stdin.readline().rstrip().split())), True)
for i in range(len(st)):
	while st[i] % 2 == 0:
		st[i] //= 2
	while st[i] % 3 == 0:
		st[i] //= 3
for i in range(1, n):
	sh = st[0] == st[i] and sh
stdout.write('Yes' if sh else 'No')


n = input()
bids = input().split(' ')
final = []
for i in range(len(bids)):
	bids[i] = int(bids[i])
for i in bids:
	while True:
		if i % 3 == 0:
			i //= 3
		if i % 2 == 0:
			i //= 2
		if i % 2 != 0 and i % 3 != 0:
			final.append(i)
			break
if final.count(final[0]) == len(bids):
	print('Yes')
else:
	print('No')


n = int(input())
v = list(map(int, input().split()))
for i in range(n):
	while v[i] % 3 == 0:
		v[i] //= 3
	while v[i] % 2 == 0:
		v[i] >>= 1
n = v.pop(0)
for i in v:
	if i != n:
		print('No')
		exit()
print('Yes')


import math

def valid(x):
	while x % 2 == 0:
		x = x // 2
	while x % 3 == 0:
		x = x // 3
	return x
n = int(input())
arr = list(map(int, input().split()))
for i in range(n):
	arr[i] = valid(arr[i])
if len(set(arr)) == 1:
	print('Yes')
else:
	print('No')


__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


n = int(input())
a = list(map(int, input().split()))

def div2(n):
	while n % 2 == 0:
		n = n / 2
	return n

def div3(n):
	while n // 3 * 3 == n:
		n = n / 3
	return n

def same(li):
	size = len(li)
	for i in range(1, size):
		if li[i] != li[i - 1]:
			return False
	return True
newlist = list()
for element in a:
	newlist.append(div3(div2(element)))
if same(newlist):
	print('Yes')
else:
	print('No')


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


def remove_int(n, divisors):
	res = n
	for d in divisors:
		while res % d == 0:
			res //= d
	return res
n = int(input())
bids = list(map(int, input().split()))
remaining_bids = [remove_int(bid, [2, 3]) for bid in bids]
print('Yes' if len(set(remaining_bids)) == 1 else 'No')


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
ok = True
for i in range(n):
	if a[i] != a[0]:
		ok = False
print('YES' if ok else 'NO')


n = int(input())
x = input()
arr = list(map(int, x.split()))
for i in range(0, n):
	while arr[i] % 2 == 0:
		arr[i] /= 2
	while arr[i] % 3 == 0:
		arr[i] /= 3
x = arr[0]
yes = 1
for i in range(0, n):
	if arr[i] != x:
		yes = 0
		break
if yes == 1:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
res = True
for i in range(n):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
	if i > 0 and a[i] != a[0]:
		res = False
		break
print('Yes' if res else 'No')


n = int(input())
m = list(map(int, input().split()))
for i in range(n):
	while m[i] % 2 == 0:
		m[i] //= 2
	while m[i] % 3 == 0:
		m[i] //= 3
if len(set(m)) == 1:
	print('Yes')
else:
	print('No')


n = int(input())
ri = lambda : map(int, input().split(' '))
a = list(ri())
for i in range(len(a)):
	while a[i] % 2 == 0:
		a[i] /= 2
	while a[i] % 3 == 0:
		a[i] /= 3
if len(set(a)) != 1:
	print('No')
else:
	print('Yes')


def check(p):
	while True:
		if p % 2 == 0:
			p = p // 2
		elif p % 3 == 0:
			p = p // 3
		else:
			return p
n = int(input())
a = list(map(int, input().split()))
x = check(a[0])
for i in range(1, n):
	temp = check(a[i])
	if temp != x:
		print('No')
		break
else:
	print('Yes')


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')


import sys
inf = float('inf')
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getvals(n):
	while n % 2 == 0:
		n //= 2
	while n % 3 == 0:
		n //= 3
	return n

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
for i in range(n):
	Arr[i] = getvals(Arr[i])
flag = 0
value = Arr[0]
for i in range(1, n):
	if Arr[i] != value:
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


input()
s = list(map(int, input().split()))
import math
for (i, j) in zip(s, s[1:]):
	x = math.gcd(i, j)
	(i, j) = (i // x, j // x)
	while i % 2 == 0:
		i //= 2
	while j % 2 == 0:
		j //= 2
	while i % 3 == 0:
		i //= 3
	while j % 3 == 0:
		j //= 3
	if i - 1 or j - 1:
		print('No')
		exit()
print('Yes')


from sys import stdin
import math
n = int(input())
l1 = list(map(int, stdin.readline().rstrip().split(' ')))
for i in range(n):
	x = l1[i]
	while x % 6 == 0:
		x //= 6
	while x % 3 == 0:
		x //= 3
	while x % 2 == 0:
		x //= 2
	l1[i] = x
l1 = set(l1)
if len(l1) == 1:
	print('YES')
else:
	print('NO')


import sys
lines = sys.stdin.read().split('\n')

def gcd(a, b):
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)

def gcds(nums):
	if len(nums) == 1:
		return nums[0]
	else:
		tmp = []
		for i in range(len(nums) // 2):
			tmp.append(gcd(nums[2 * i], nums[2 * i + 1]))
		if len(nums) % 2 != 0:
			tmp.append(nums[-1])
		return gcds(tmp)

def check(num):
	while num % 2 == 0:
		num = num // 2
	while num % 3 == 0:
		num = num // 3
	if num > 1:
		return False
	else:
		return True
n = int(lines[0])
nums = list(map(int, lines[1].split(' ')))
g = gcds(nums)
for num in nums:
	case = num // g
	if not check(case):
		print('No')
		sys.exit(0)
print('Yes')


n = int(input())
A = []
A = [int(x) for x 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
for i in A:
	if i != A[0]:
		print('No')
		exit()
print('Yes')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect, insort
from time import perf_counter
from fractions import Fraction
import copy
from copy import deepcopy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')
x = 0
n = L()[0]
A = L()
for ele in A:
	x = gcd(x, ele)
for i in range(n):
	A[i] //= x
x = set(A)
for ele in x:
	while ele % 3 == 0:
		ele //= 3
	while ele % 2 == 0:
		ele //= 2
	if ele != 1:
		print('No')
		exit()
print('Yes')
endtime = time.time()


__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())
c = list(map(int, input().split()))
k = c[0]
l = c[0]
while k % 3 == 0 or k % 2 == 0:
	if k % 3 == 0:
		k //= 3
	else:
		k //= 2
	l = k
for i in range(n):
	k = c[i]
	while k % 3 == 0 or k % 2 == 0:
		if k % 3 == 0:
			k //= 3
		else:
			k //= 2
	if l != k:
		print('No')
		break
else:
	print('Yes')


n = int(input())
var = [int(x) for x in input().split()]
ansSet = set()
for el in var:
	ans = el
	while ans % 2 == 0:
		ans = ans // 2
	while ans % 3 == 0:
		ans = ans // 3
	ansSet.add(ans)
if len(ansSet) == 1:
	print('Yes')
else:
	print('No')


def main():
	gcd = lambda a, b: a if b == 0 else gcd(b, a % b)
	n = int(input())
	a = list(map(int, input().split()))
	G = a[0]
	for i in range(n):
		while a[i] % 3 == 0:
			a[i] //= 3
		while a[i] % 2 == 0:
			a[i] //= 2
		G = gcd(a[i], G)
	f = not bool(sum((G != a[i] for i in range(n))))
	print('Yes' if f else 'No')
main()


from sys import stdin
from sys import stdout
input()
l = list(map(int, set(stdin.readline().split())))
c = l[-1]
while not c % 2:
	c //= 2
while not c % 3:
	c //= 3
for i in l:
	while not i % 2:
		i //= 2
	while not i % 3:
		i //= 3
	if i != c:
		stdout.write('No')
		exit()
print('Yes')


import sys

def mdc(a, b):
	while a % b != 0:
		aux = b
		b = a % b
		a = aux
	return b

def mmc(a, b):
	return a * (b / mdc(a, b))
n = int(input())
bids = list(map(int, input().split()))
multiplo = bids[0]
for i in range(len(bids) - 1):
	e1 = bids[i]
	e2 = bids[i + 1]
	multiplo = mmc(multiplo, e2)
	x = multiplo / e1
	pf = 2
	while x % pf == 0:
		x //= pf
	pf = 3
	while x % pf == 0:
		x //= pf
	if x != 1:
		print('No')
		sys.exit()
x = multiplo / e2
pf = 2
while x % pf == 0:
	x //= pf
pf = 3
while x % pf == 0:
	x //= pf
if x != 1:
	print('No')
	sys.exit()
print('Yes')


def poker(lst):
	for i in range(len(lst)):
		while lst[i] % 2 == 0:
			lst[i] //= 2
		while lst[i] % 3 == 0:
			lst[i] //= 3
	for i in range(1, len(lst)):
		if lst[i] != lst[i - 1]:
			return 'No'
	return 'Yes'
n = int(input())
a = [int(j) for j in input().split()]
print(poker(a))


from fractions import Fraction

def check(n):
	while n % 3 == 0:
		n //= 3
	while n % 2 == 0:
		n //= 2
	if n == 1:
		return True
	return False
n = int(input())
s = set(map(int, input().split()))
mx = max(s)
for e in s:
	f = Fraction(mx, e)
	if not (check(f.numerator) and check(f.denominator)):
		print('No')
		break
else:
	print('Yes')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far
from math import *
for _ in range(1):
	n = int(input())
	li = list(map(int, input().split()))
	for i in range(n):
		while li[i] % 2 == 0:
			li[i] //= 2
		while li[i] % 3 == 0:
			li[i] //= 3
	f = 1
	for i in range(n):
		if li[i] != li[0]:
			print('No')
			f = 0
			break
	if f:
		print('Yes')


def gdc(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a
n = int(input())
lista = list(map(int, input().split()))
resultado = lista[0]
for i in lista:
	resultado = i / gdc(i, resultado) * resultado
teste = True
if resultado == float('inf'):
	print('No')
else:
	for i in lista:
		aux = int(resultado) / i
		while aux > 1 and (aux % 2 == 0 or aux % 3 == 0):
			if aux % 2 == 0:
				aux /= 2
			else:
				aux /= 3
		if aux > 1:
			print('No')
			teste = False
			break
	if teste:
		print('Yes')


import math
n = int(input())
a = [int(i) for i in input().split()]
g = 0
for i in a:
	g = math.gcd(g, i)
for i in range(len(a)):
	a[i] = a[i] // g
f = False
for i in a:
	while i % 2 == 0:
		i = i // 2
	while i % 3 == 0:
		i = i // 3
	if i != 1:
		f = True
if f:
	print('No')
else:
	print('Yes')


def nod(a, b):
	while a * b:
		if a > b:
			a %= b
		else:
			b %= a
	return a + b
n = int(input())
l = [int(j) for j in input().split()]
nd = l[0]
for i in range(1, n):
	nd = nod(nd, l[i])
flag = 1
for i in range(n):
	k = l[i] // nd
	while k % 3 == 0:
		k //= 3
	while k % 2 == 0:
		k //= 2
	if k != 1:
		flag = 0
		break
if flag:
	print('Yes')
else:
	print('No')


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]

def Lcm(a, b):
	return a * b // gcd(a, b)

def possible(x, y):
	k = y // x
	if k % 3 == 0 or k % 2 == 0:
		return True
	return False
n = int(input())
a = array()
ans = set()
for i in a:
	k = i
	while k % 2 == 0:
		k = k // 2
	while k % 3 == 0:
		k = k // 3
	ans.add(k)
if len(ans) == 1:
	print('YES')
else:
	print('NO')


n = int(input())
l = [int(s) for s in input().split(' ')]
buf = True
minfactor = 0

def fac(a):
	while a != 0 and a % 2 == 0:
		a = a // 2
	while a != 0 and a % 3 == 0:
		a = a // 3
	return a
for i in range(len(l)):
	current = fac(l[i])
	if minfactor != 0 and minfactor != current:
		buf = False
		break
	elif minfactor != current:
		minfactor = current
if buf:
	print('Yes')
else:
	print('No')


import sys
import collections
from collections import Counter
import itertools
import math
import timeit
input = sys.stdin.readline

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def f(n):
	while not n % 2:
		n //= 2
	while not n % 3:
		n //= 3
	return n
n = ii()
d = li()
t = f(d[0])
print('Yes') if all((f(d[i]) == t for i in range(1, n))) else print('No')


n = int(input())
lst = [*map(int, input().split())]
from math import gcd
g = lst[0]
for (i, x) in enumerate(lst):
	g = gcd(g, x)
for (i, x) in enumerate(lst):
	a = x // g
	while a % 2 == 0:
		a = a // 2
	while a % 3 == 0:
		a = a // 3
	if a > 1:
		from sys import exit
		print('No')
		exit()
print('Yes')


n = int(input())
n = None
f = True
for i in map(int, input().split()):
	while i % 2 == 0:
		i //= 2
	while i % 3 == 0:
		i //= 3
	if n == None:
		n = i
	elif i != n:
		f = False
		break
if f:
	print('Yes')
else:
	print('No')


from sys import stdin, stdout
from collections import Counter
from collections import defaultdict
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math
ai = lambda : list(map(int, stdin.readline().split()))
ei = lambda : map(int, stdin.readline().split())
ip = lambda : int(stdin.readline().strip())
n = ip()
li = ai()
MAX = max(li)
for i in range(n):
	while li[i] % 2 == 0:
		li[i] //= 2
	while li[i] % 3 == 0:
		li[i] //= 3
if len(set(li)) == 1:
	print('Yes')
else:
	print('No')


n = int(input())
s = list(map(int, input().split()))
for i in range(n):
	flag = True
	while flag:
		if s[i] % 2 == 0:
			s[i] = s[i] // 2
		if s[i] % 3 == 0:
			s[i] = s[i] // 3
		if s[i] % 2 != 0 and s[i] % 3 != 0:
			flag = False
flag = True
if n > 1:
	for i in range(1, n):
		if s[i] != s[i - 1]:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')
else:
	print('YES')


from math import ceil
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	l = 0
	r = 40
	while l + 1 < r:
		m = (l + r) // 2
		if a[i] % 2 ** m == 0:
			l = m
		else:
			r = m
	a[i] //= 2 ** l
	l = 0
	r = 30
	while l + 1 < r:
		m = (l + r) // 2
		if a[i] % 3 ** m == 0:
			l = m
		else:
			r = m
	a[i] //= 3 ** l
k = a[0]
flag = True
for i in range(len(a)):
	if a[i] != k:
		print('No')
		flag = False
		break
if flag == True:
	print('Yes')


n = int(input())
deleter = 0
accepted = True
for i in map(int, input().split()):
	while i % 2 == 0:
		i //= 2
	while i % 3 == 0:
		i //= 3
	if not deleter:
		deleter = i
	elif deleter != i:
		accepted = False
		break
print('Yes' if accepted else 'No')


import math
n = int(input())
ls = [int(a) for a in input().split()]
bp = 0
for i in range(n - 1):
	a = ls[i] * ls[i + 1] // math.gcd(ls[i], ls[i + 1])
	ls1 = []
	ls1.append(a // ls[i])
	ls1.append(a // ls[i + 1])
	for a in ls1:
		while a & 1 == 0 and a > 1:
			a = a >> 1
		an = round(math.log(a) / math.log(3))
		if 3 ** an != a:
			print('NO')
			bp = 1
			break
	if bp == 1:
		break
if 3 ** an == a:
	print('YES')


from sys import exit
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')
		exit()
print('Yes')


n = int(input())
l = list(map(int, input().split()))
for i in range(len(l)):
	while l[i] % 2 == 0:
		l[i] //= 2
	while l[i] % 3 == 0:
		l[i] //= 3
for i in range(len(l)):
	if l[i] != l[0]:
		print('NO')
		exit()
print('YES')


x = int(input())
arr = [int(new) for new in input().split()]
click = 'Yes'
for i in range(x):
	while arr[i] % 3 == 0:
		arr[i] //= 3
	while arr[i] % 2 == 0:
		arr[i] //= 2
for i in arr:
	if arr[0] != i:
		click = 'No'
		break
print(click)


def cal(x):
	while x % 2 == 0:
		x = x / 2
	while x % 3 == 0:
		x = x / 3
	return x
n = int(input())
a = list(map(int, input().strip().split(' ')))
flag = 1
test = cal(a[0])
for i in range(n):
	if cal(a[i]) != test:
		flag = 0
		break
if flag == 1:
	print('Yes')
else:
	print('No')


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	for i in range(len(arr)):
		while True:
			if arr[i] % 2 == 0:
				arr[i] = arr[i] // 2
			if arr[i] % 3 == 0:
				arr[i] = arr[i] // 3
			if arr[i] % 2 != 0 and arr[i] % 3 != 0:
				break
	for i in range(len(arr) - 1):
		if arr[i] != arr[i + 1]:
			print('No')
			return
	print('Yes')
	return
main()


n = int(input())
arr = list(map(int, input().split()))
for i in range(n):
	while arr[i] % 2 == 0:
		arr[i] //= 2
	while arr[i] % 3 == 0:
		arr[i] //= 3
eq = True
for i in range(1, n):
	if arr[i] != arr[i - 1]:
		eq = False
if eq:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
ans = 'Yes'
for i in range(n):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
for i in range(1, n):
	if a[i] != a[0]:
		ans = 'No'
print(ans)


def rem(x):
	for i in range(2, 4):
		while x % i == 0:
			x //= i
	return x
n = int(input())
result = 'Yes'
data = [int(i) for i in input().split()]
b = rem(data.pop())
for i in data:
	if rem(i) != b:
		result = 'No'
		break
print(result)


from sys import stdin
raw_input = stdin.readline
xrange = range

def get_line(typ):
	return list(map(typ, stdin.readline().split()))

def gcd(a, b):
	return a if b == 0 else gcd(b, a % b)
n = int(raw_input())
a = get_line(int)
cnt = 0
mp = {}
for i in xrange(n):
	while a[i] % 3 == 0:
		a[i] //= 3
	while a[i] % 2 == 0:
		a[i] //= 2
	if a[i] not in mp:
		mp[a[i]] = True
		cnt += 1
if cnt != 1:
	print('No')
else:
	print('Yes')


import sys
import math

def read_input(input_path=None):
	if input_path is None:
		f = sys.stdin
	else:
		f = open(input_path, 'r')
	n = int(f.readline())
	a = list(map(int, f.readline().split()))
	return (n, a)

def sol(n, a):
	for i in range(n):
		while a[i] % 2 == 0:
			a[i] //= 2
		while a[i] % 3 == 0:
			a[i] //= 3
	for i in range(1, n):
		if a[i] != a[0]:
			return ['NO']
	return ['YES']

def solve(input_path=None):
	return sol(*read_input(input_path))

def main():
	for line in sol(*read_input()):
		print(f'{line}')
main()


def fun(num):
	while num % 2 == 0:
		num //= 2
	while num % 3 == 0:
		num //= 3
	return num
n = int(input())
flag = True
p = 0
c = 0
for i in input().split():
	if p == 0:
		p = fun(int(i))
	else:
		c = fun(int(i))
		if c != p:
			flag = False
print('Yes') if flag else print('No')


n = int(input())
a = input().split(' ')
f = 2
b = 1
g = True
a[0] = m = int(a[0])
while f <= m ** 0.5:
	if a[0] % f == 0:
		if f >= 4:
			b *= f
		a[0] /= f
	else:
		f += 1
b *= a[0]
for c in range(1, n):
	a[c] = int(a[c])
	d = a[c] / b
	if d % 1 != 0:
		g = False
		break
	else:
		f = 2
		while d != 1:
			if d % f == 0:
				d /= f
			else:
				f += 1
			if f == 4:
				g = False
				break
		if not g:
			break
if g:
	print('Yes')
else:
	print('No')


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = sorted(il())
for i in range(n):
	while l[i] % 2 == 0:
		l[i] //= 2
	while l[i] % 3 == 0:
		l[i] //= 3
print('Yes' if all((l[i] == l[0] for i in range(n))) else 'No')


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


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 1000000007

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

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def main():
	n = int(input())
	arr = array()
	prev = None
	res = 'YES'
	for i in range(n):
		while arr[i] % 2 == 0:
			arr[i] //= 2
		while arr[i] % 3 == 0:
			arr[i] //= 3
		if prev == None:
			prev = arr[i]
		elif prev != arr[i]:
			res = 'NO'
	print(res)
t = 1
for _ in range(t):
	main()


n = int(input())
a = [int(i) for i in input().split()]
ans = []
for x in a:
	while x % 2 == 0:
		x //= 2
	while x % 3 == 0:
		x //= 3
	ans.append(int(x))
yes = True
for x in ans:
	if x != ans[0]:
		yes = False
print('Yes' if yes else 'NO')


N = input()
l = map(int, input().split())
n = 0
p = True
for i in l:
	t = i
	while t % 2 == 0:
		t /= 2
	while t % 3 == 0:
		t /= 3
	if n > 0 and n != t:
		p = False
		break
	else:
		n = t
print('Yes' if p else 'No')


N = int(input())
s = input().split(' ')
a = [int(x) for x in s]
for i in range(N):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
ans = True
for i in range(1, N):
	if a[i] != a[i - 1]:
		ans = False
		break
if ans:
	print('Yes')
else:
	print('No')


def f(x):
	while x % 2 == 0:
		x //= 2
	while x % 3 == 0:
		x //= 3
	return x
n = int(input())
l_n = [f(x) for x in list(map(int, input().split()))]
print('Yes' if min(l_n) == max(l_n) else 'No')


from sys import stdin, stdout
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))

def fac(n, d):
	ans = 0
	while n % d == 0:
		ans += 1
		n //= d
	return ans
f2 = [fac(i, 2) for i in a]
f3 = [fac(i, 3) for i in a]
m2 = max(f2)
m3 = max(f3)
for i in range(n):
	if f2[i] < m2:
		a[i] *= 2 ** (m2 - f2[i])
	if f3[i] < m3:
		a[i] *= 3 ** (m3 - f3[i])
if a.count(a[0]) != n:
	stdout.write('No')
else:
	stdout.write('Yes')


import math as m
n = int(input())
x = list(map(int, input().split()))
x.sort()
s = set()
for i in x:
	while i % 2 == 0 or i % 3 == 0:
		if i % 2 == 0:
			i /= 2
		if i % 3 == 0:
			i /= 3
	s.add(i)
if len(s) == 1:
	print('Yes')
else:
	print('No')


n = int(input())
bid = list(map(int, input().split()))
flag = 0
tep = bid[0]
while tep % 3 == 0:
	tep /= 3
while tep % 2 == 0:
	tep /= 2
remain = tep
for i in range(1, n):
	temp = bid[i]
	while temp % 3 == 0:
		temp /= 3
	while temp % 2 == 0:
		temp /= 2
	if temp != remain:
		print('NO')
		flag = 1
		break
if flag == 0:
	print('YES')


n = int(input())
S = set(list(map(int, input().split())))
L = list(S)
while True:
	d = 0
	for i in range(len(L)):
		if L[i] % 2 == 0:
			L[i] = L[i] // 2
			d = 1
	if d == 0:
		break
while True:
	d = 0
	for i in range(len(L)):
		if L[i] % 3 == 0:
			L[i] = L[i] // 3
			d = 1
	if d == 0:
		break
S = set(L)
if len(S) == 1:
	print('YES')
else:
	print('NO')


import math
import sys, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
n = I()
l = L()
g = l[0]
for i in range(n):
	g = math.gcd(g, l[i])
for i in range(n):
	k = l[i] // g
	while k % 2 == 0:
		k //= 2
	while k % 3 == 0:
		k //= 3
	if k != 1:
		print('No')
		exit()
print('Yes')


input()
a = 0
for t in map(int, input().split()):
	while t % 2 == 0:
		t //= 2
	while t % 3 == 0:
		t //= 3
	if not a:
		a = t
	elif a != t:
		print('No')
		exit()
print('Yes')


def euc(x, y):
	if y == 0:
		return x
	return euc(y, x % y)

def judge(x):
	m = x
	while m % 2 == 0:
		m //= 2
	while m % 3 == 0:
		m //= 3
	return m == 1
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 'Yes'
for i in range(0, N - 1):
	X = A[i] * A[N - 1] // euc(A[i], A[N - 1])
	if not judge(X // euc(A[i], A[N - 1])):
		ans = 'No'
		break
print(ans)


leng = int(input())
vals = list(map(lambda x: int(x), input().split(' ')))
sbt = -1
for s in vals:
	while not s % 2:
		s = s // 2
	while not s % 3:
		s = s // 3
	if sbt == -1:
		sbt = s
	elif sbt != s:
		print('No')
		sbt = 0
		break
if sbt:
	print('Yes')


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')


def fun(n):
	while n % 2 == 0:
		n = int(n / 2)
	while n % 3 == 0:
		n = int(n / 3)
	return n
n = int(input())
s = 1
p = [int(x) for x in input().split()]
for i in range(0, n - 1):
	if fun(p[i]) != fun(p[i + 1]):
		s = 0
		break
if s == 0:
	print('No')
else:
	print('Yes')


n = int(input())
bids = [int(x) for x in input().split()]
a = 0
flag = True
for i in bids:
	while i % 2 == 0:
		i = i // 2
	while i % 3 == 0:
		i = i // 3
	if a == 0:
		a = i
	elif i != a:
		print('No')
		flag = False
		break
if flag:
	print('Yes')


x = int(input())
(*li,) = map(int, input().split())
li1 = []
for i in li:
	while i % 2 == 0:
		i //= 2
	while i % 3 == 0:
		i //= 3
	li1.append(i)
for i in li1[1:]:
	if i != li1[0]:
		print('No')
		break
else:
	print('Yes')


n = int(input())
numbers = [int(x) for x in input().split()]
s = set()
for i in numbers:
	aux = i
	while True:
		if aux % 2 == 0:
			aux /= 2
		elif aux % 3 == 0:
			aux /= 3
		else:
			break
	s.add(aux)
result = 'No'
if len(s) == 1:
	result = 'Yes'
print(result)


n = int(input())
l = list(map(int, input().split()))
a = -1
c = 0
for i in range(n):
	while l[i] % 2 == 0:
		l[i] = l[i] // 2
	while l[i] % 3 == 0:
		l[i] = l[i] // 3
	if a == -1:
		a = l[i]
	elif a != l[i]:
		c = 1
		break
if c == 1:
	print('No')
else:
	print('Yes')


from fractions import gcd
n = int(input())
bids = list(map(int, input().split()))
a = bids[0]
for i in range(1, n):
	a = gcd(a, bids[i])
for i in bids:
	b = i // a
	while b % 2 == 0:
		b = b // 2
	while b % 3 == 0:
		b = b // 3
	if b != 1:
		print('No')
		exit(0)
print('Yes')


import traceback
import math

def main():
	N = int(input())
	nums = list(map(int, input().split()))

	def get(n):
		while n % 2 == 0 or n % 3 == 0:
			if n % 2 == 0:
				n //= 2
			if n % 3 == 0:
				n //= 3
		return n
	x = get(nums[0])
	for i in range(1, N):
		if x != get(nums[i]):
			return 'No'
	return 'Yes'
try:
	ans = main()
	print(ans)
except Exception:
	traceback.print_exc()


from sys import stdin
import math
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().split()))
for i in range(len(arr)):
	while arr[i] % 2 == 0:
		arr[i] //= 2
	while arr[i] % 3 == 0:
		arr[i] //= 3
c = arr[0]
for i in range(1, len(arr)):
	if arr[i] != c:
		print('No')
		break
else:
	print('Yes')


def divide(a):
	while a % 2 == 0:
		a = a // 2
	while a % 3 == 0:
		a = a // 3
	return a
n = int(input())
arr = input()
arr = arr.split(' ')
arr = list(map(int, arr))
arr = list(map(divide, arr))
ref = arr[0]
tt = 0
for x in arr:
	if x != ref:
		tt = 1
		break
if tt == 1:
	print('No')
else:
	print('Yes')


n = int(input())
l = [int(i) for i in input().split()]
for i in range(n):
	while l[i] % 2 == 0:
		l[i] //= 2
	while l[i] % 3 == 0:
		l[i] //= 3
print('YES' if all((l[i] == l[0] for i in range(1, n))) else 'NO')


n = int(input())
a = list(map(int, input().split()))
b = set()
for x in a:
	while x % 2 == 0:
		x /= 2
	while x % 3 == 0:
		x /= 3
	b.add(x)
if len(b) == 1:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout, setrecursionlimit
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm, accumulate
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return input()

def num():
	return int(input())

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def pmat(A):
	for ele in A:
		print(*ele, end='\n')

def pmat2(A):
	for ele in A:
		for j in ele:
			print(j, end='')
		print()

def seive(r):
	prime = [1 for i in range(r + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(r + 1):
		if prime[i]:
			for j in range(2 * i, r + 1, i):
				prime[j] = 0
	return prime
n = int(data())
a = L()
for i in range(n):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
t = a[0]
for i in a:
	if t != i:
		exit(print('No'))
print('Yes')
endtime = time.time()


def reduce(x):
	while x % 3 == 0:
		x //= 3
	while x % 2 == 0:
		x //= 2
	return x
(_, bets) = (input(), map(int, input().split()))
print('YES' if len(set(map(reduce, bets))) == 1 else 'NO')


from bisect import bisect_right
n = int(input())
a = list(map(int, 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
flag = 0
for i in range(1, n):
	if a[i] != a[0]:
		flag = 1
if flag == 1:
	print('No')
else:
	print('Yes')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = LI()
	s = set()
	for c in a:
		while c % 2 == 0:
			c //= 2
		while c % 3 == 0:
			c //= 3
		s.add(c)
	if len(s) > 1:
		return 'No'
	return 'Yes'
print(main())


n = int(input())
a = list([int(x) for x in input().split()])
check = set({})
i = 0
flag = 0
for i in range(len(a)):
	while a[i] % 2 == 0:
		a[i] /= 2
	while a[i] % 3 == 0:
		a[i] /= 3
	check.add(a[i])
if len(check) == 1:
	print('YES')
else:
	print('NO')


players = int(input())
values = [*map(int, input().split())]
resp = 'Yes'
for i in range(players):
	while values[i] % 2 == 0:
		values[i] = values[i] // 2
	while values[i] % 3 == 0:
		values[i] = values[i] // 3
minimos = set(values)
if len(minimos) > 1:
	resp = 'No'
print(resp)


from sys import stdin
from math import gcd
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
g = s[0]
mul = s[0]
st = set()
arr = set()
for i in range(n):
	x = s[i]
	while x % 2 == 0:
		x = x // 2
	while x % 3 == 0:
		x = x // 3
	arr.add(x)
if len(arr) == 1:
	print('Yes')
else:
	print('No')


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def isDoubleAndTriple(a):
	while a % 2 == 0:
		a = a // 2
	while a % 3 == 0:
		a = a // 3
	return a == 1
n = int(input())
a = list(map(int, input().split(' ')))
m = max(a)
for i in range(n):
	g = gcd(m, a[i])
	if not isDoubleAndTriple(m // g) or not isDoubleAndTriple(a[i] // g):
		print('No')
		exit(0)
print('Yes')


from math import gcd
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	while l[i] % 2 == 0:
		l[i] = l[i] // 2
	while l[i] % 3 == 0:
		l[i] = l[i] // 3
a = l[0]
lol = 0
for i in range(1, n):
	if l[i] != a:
		lol = 1
		break
if lol == 1:
	print('No')
else:
	print('Yes')


n = int(input())
bids = list(map(int, input().split()))
for i in range(n):
	while bids[i] % 2 == 0:
		bids[i] /= 2
	while bids[i] % 3 == 0:
		bids[i] /= 3
is_all_equal = True
for i in range(n - 1):
	if bids[i] != bids[i + 1]:
		is_all_equal = False
		break
if is_all_equal:
	print('Yes')
else:
	print('No')


import math
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
if a.count(a[0]) == n:
	print('Yes')
else:
	print('No')


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


def reduce(x):
	res = int(x)
	while not res % 2:
		res //= 2
	while not res % 3:
		res //= 3
	return res
n = input()
print('Yes' if len(set(map(reduce, input().split()))) == 1 else 'No')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def check(n):
	while n % 2 == 0:
		n //= 2
	while n % 3 == 0:
		n //= 3
	if n == 1:
		return True
	return False
n = int(input())
l = list(map(int, input().split()))
g = l[0]
import math
for i in range(1, n):
	g = math.gcd(l[i], g)
flag = 0
for i in range(n):
	if check(l[i] // g) == False:
		flag = 1
		break
if flag == 0:
	print('Yes')
else:
	print('No')


from sys import stdin
a = int(stdin.readline())
s = set()
for i in map(int, stdin.readline().split()):
	k = i
	while k % 2 == 0:
		k //= 2
	while k % 3 == 0:
		k //= 3
	s.add(k)
if len(s) == 1:
	print('Yes')
else:
	print('No')


def change(n):
	while n and (not n % 2):
		n /= 2
	while n and (not n % 3):
		n /= 3
	return n
n = int(input())
a = [int(i) for i in input().split()]
a = [change(i) for i in a]
print('Yes' if len(set(a)) == 1 else 'No')


import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))

def pgcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def test2and3(n):
	while n % 2 == 0:
		n = n // 2
	while n % 3 == 0:
		n = n // 3
	return n
p = a[0]
for ai in a[1:]:
	p = pgcd(p, ai)
for ai in a:
	if test2and3(ai // p) > 1:
		print('No')
		break
else:
	print('Yes')


from math import ceil, sqrt, floor

def isPerfectSquare(x):
	if x >= 0:
		sr = sqrt(x)
		return sr % 1 == 0
	return False

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
open_list = ['[', '{', '(']
close_list = [']', '}', ')']

def check(myStr):
	stack = []
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0 and open_list[pos] == stack[len(stack) - 1]:
				stack.pop()
			else:
				return False
	if len(stack) == 0:
		return True
	else:
		return False
t = 1
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	maxx = max(arr)
	flag = True
	for i in range(n):
		while arr[i] % 6 == 0:
			arr[i] = arr[i] // 6
		while arr[i] % 2 == 0:
			arr[i] = arr[i] // 2
		while arr[i] % 3 == 0:
			arr[i] = arr[i] // 3
		if i > 0 and arr[i - 1] != arr[i]:
			print('No')
			flag = False
			break
	if flag:
		print('Yes')


__author__ = 'Rock'
n = int(input())
col = list(map(int, input().split()))
for i in range(0, n):
	while col[i] % 2 == 0:
		col[i] //= 2
	while col[i] % 3 == 0:
		col[i] //= 3
	if col[i] != col[0]:
		print('No')
		exit()
print('Yes')


def get_lcm(a, b):
	ab = a * b
	while b != 0:
		t = b
		b = a % b
		a = t
	return int(ab / a)

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

def main():
	n = int(input())
	bids = [int(x) for x in input().split()]
	lcm = bids[0]
	for i in range(1, n):
		lcm = get_lcm(lcm, bids[i])
		div = lcm // bids[i - 1]
		if not check(div):
			return 'No'
	if not check(lcm // bids[-1]):
		return 'No'
	else:
		return 'Yes'
print(main())


def f(num):
	while num != 1:
		if num % 2 == 0:
			num /= 2
		elif num % 3 == 0:
			num /= 3
		else:
			return num
n = int(input())
nums = [int(i) for i in input().split()]
res = False
k = f(nums[0])
for num in nums:
	if k != f(num):
		res = True
res = not res
if res:
	print('Yes')
else:
	print('No')


n = int(input())
l = list(map(int, input().split()))
for i in range(len(l)):
	while l[i] % 2 == 0:
		l[i] /= 2
	while l[i] % 3 == 0:
		l[i] /= 3
b = True
for i in l:
	if i != l[0]:
		b = False
		break
if b:
	print('Yes')
else:
	print('No')


def main():
	import sys
	from fractions import gcd
	n = int(input())
	a = [int(i) for i in input().split()]
	t = a[0]
	for i in range(1, n):
		t = gcd(a[i], t)
	a = [a[i] // t for i in range(n)]
	for i in range(n):
		while a[i] % 2 == 0:
			a[i] //= 2
		while a[i] % 3 == 0:
			a[i] //= 3
		if a[i] > 1:
			print('No')
			sys.exit()
	print('Yes')
main()


def divide_by_2_and_3(n):
	while n % 2 == 0:
		n //= 2
	while n % 3 == 0:
		n //= 3
	return n
_ = input()
bids = list(set(map(int, input().split())))
bids = map(lambda x: divide_by_2_and_3(x), bids)
print('Yes' if len(set(bids)) == 1 else 'No')


N = int(input())
x = [int(i) for i in input().split()]
for i in range(N):
	while x[i] % 2 == 0:
		x[i] //= 2
	while x[i] % 3 == 0:
		x[i] //= 3
T = True
for i in range(N - 1):
	if x[i] != x[i + 1]:
		T = False
print('Yes' if T else 'No')


def prime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def p(n):
	if prime(n) and n not in [2, 3]:
		return n
	else:
		if n in [2, 3]:
			return 1
		i = 2
		result = 2
		while i < 4:
			if n % i == 0:
				n //= i
			else:
				i += 1
	return n
n = int(input())
array = list(map(int, input().split()))
f = True
used = []
if array[0] == array[1]:
	for i in array:
		if i not in used:
			used.append(i)
	array = used
a = p(array[0])
for i in array:
	if p(i) != a:
		f = False
		break
if f:
	print('Yes')
else:
	print('No')


import math
from collections import defaultdict
for _ in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	maxo = max(a)
	an = True
	for i in range(n):
		k = a[i]
		while True:
			if k % 2 != 0 and k % 3 != 0:
				break
			if k % 2 == 0:
				k = k / 2
			if k % 3 == 0:
				k = k / 3
		a[i] = k
	if len(set(a)) == 1:
		print('Yes')
	else:
		print('No')


def func(a):
	while a % 2 == 0:
		a = a // 2
	while a % 3 == 0:
		a = a // 3
	return a
n = int(input())
a = input().split()
per = 0
per2 = func(int(a[0]))
a[0] = per2
per3 = 0
for i in range(1, len(a)):
	per3 = func(int(a[i]))
	a[i] = per3
	if per2 != per3:
		per = 1
		break
if per == 0:
	print('YES')
else:
	print('NO')


def pseudo_factor(x):
	while x % 2 == 0 or x % 3 == 0:
		if x % 2 == 0:
			x = x // 2
		else:
			x = x // 3
	return x
n = int(input(' '))
c = [int(x) for x in input().split(' ')]
p = pseudo_factor(c[0])
f = 0
for i in range(1, n):
	if p != pseudo_factor(c[i]):
		f = 1
		break
if f == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
p2 = 2 ** 7
p3 = 3 ** 7
for i in range(n):
	while a[i] % p3 == 0:
		a[i] /= p3
		goon = True
	while a[i] % p2 == 0:
		a[i] /= p2
		goon = True
	while a[i] % 3 == 0:
		a[i] /= 3
		goon = True
	while a[i] % 2 == 0:
		a[i] /= 2
		goon = True
ans = 'Yes'
for i in range(1, n):
	if a[0] != a[i]:
		ans = 'No'
print(ans)


n = int(input())
a = list(map(int, input().split()))
val = -1
for i in range(n):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
	if val == -1:
		val = a[i]
	elif val != a[i]:
		print('No')
		exit(0)
print('Yes')


from bisect import insort, bisect_right, bisect_left
from sys import stdout, stdin, setrecursionlimit
from heapq import heappush, heappop, heapify
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from string import *
from queue import *
from math import *
from re import *
from os import *

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
(graph, mod, szzz) = ({}, 10 ** 9 + 7, lambda : sorted(zzz()))

def getStr():
	return input()

def getInt():
	return int(input())

def listStr():
	return list(input())

def getStrs():
	return input().split()

def isInt(s):
	return '0' <= s[0] <= '9'

def input():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in input().split()]

def output(answer, end='\n'):
	stdout.write(str(answer) + end)

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def getPrimes(N=10 ** 5):
	SN = int(sqrt(N))
	sieve = [i for i in range(N + 1)]
	sieve[1] = 0
	for i in sieve:
		if i > SN:
			break
		if i == 0:
			continue
		for j in range(2 * i, N + 1, i):
			sieve[j] = 0
	prime = [i for i in range(N + 1) if sieve[i] != 0]
	return prime

def primeFactor(n, prime=getPrimes()):
	lst = []
	mx = int(sqrt(n)) + 1
	for i in prime:
		if i > mx:
			break
		while n % i == 0:
			lst.append(i)
			n //= i
	if n > 1:
		lst.append(n)
	return lst
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
daysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
n = getInt()
arr = zzz()
for i in range(n):
	while arr[i] % 2 == 0:
		arr[i] //= 2
	while arr[i] % 3 == 0:
		arr[i] //= 3
print('YES' if len(set(arr)) == 1 else 'NO')


def prime_exp(n, p):
	count = 0
	while n % p == 0:
		count += 1
		n = n / p
	return count

def shade32off(n):
	two = prime_exp(n, 2)
	three = prime_exp(n, 3)
	ans = n // 2 ** two
	ans = ans // 3 ** three
	return ans
n = int(input())
arr = list(map(int, input().split()))
prev = shade32off(arr[0])
flag = 0
for i in arr:
	yo = shade32off(i)
	if yo != prev:
		flag = 1
		print('No')
		break
if flag == 0:
	print('Yes')


n = int(input())
l = input().split()
for a in range(n):
	while True:
		if int(l[a]) % 2 == 0:
			l[a] = int(l[a]) // 2
		elif int(l[a]) % 3 == 0:
			l[a] = int(l[a]) // 3
		else:
			break
check = int(l[0])
for i in range(n):
	if check != int(l[i]):
		print('No')
		break
else:
	print('Yes')


n = int(input())
import math
t = list(map(int, input().split()))
for k in range(n):
	while True:
		if t[k] % 6 == 0:
			t[k] //= 6
		elif t[k] % 2 == 0:
			t[k] //= 2
		elif t[k] % 3 == 0:
			t[k] //= 3
		else:
			break
if len(set(t)) == 1:
	print('Yes')
else:
	print('No')


def removetwothree(n):
	while n % 2 == 0:
		n = n / 2
	while n % 3 == 0:
		n = n / 3
	return n
n = int(input())
nums = [int(i) for i in input().split()]
firstone = removetwothree(nums[0])
bad = False
for i in range(1, len(nums)):
	nextone = removetwothree(nums[i])
	if nextone != firstone:
		print('No')
		bad = True
		break
if not bad:
	print('Yes')


import os
import sys
n = int(input())
arr = [int(n) for n in input().split()]
for i in range(0, len(arr)):
	while arr[i] % 2 == 0 and arr[i] > 1:
		arr[i] /= 2
	while arr[i] % 3 == 0 and arr[i] > 1:
		arr[i] /= 3
flag = True
for i in range(0, len(arr)):
	if not arr[i] == arr[i - 1]:
		flag = False
if flag == True:
	print('Yes')
else:
	print('No')


def dividers(n):
	if n == 1:
		return set()
	elif n == 2:
		a = set()
		a.add(2)
		return a
	elif n == 3:
		a = set()
		a.add(3)
		return a
	i = 2
	dividers = []
	while n > 1 and i * i <= n:
		if n % i == 0:
			if i in dividers:
				if i != 2 and i != 3:
					dividers.append(i)
			else:
				dividers.append(i)
			n //= i
			continue
		i += 1
	if i * i > n and n != 2 and (n != 3):
		dividers.append(n)
	ans = set()
	i1 = 0
	i2 = 0
	while i2 < len(dividers):
		if dividers[i2] != dividers[i1]:
			ans.add(dividers[i1] ** (i2 - i1))
			i1 = i2
		else:
			i2 += 1
	ans.add(dividers[i1] ** (i2 - i1))
	return ans
n = int(input())
mas = list(set((int(e) for e in input().split())))
mas[0] = dividers(mas[0])
ans = True
for_help = set()
for_help.add(2)
for_help.add(3)
for i in range(len(mas) - 1):
	mas[i + 1] = dividers(mas[i + 1])
	if len((mas[i] ^ mas[i + 1]) - for_help) != 0:
		ans = False
		break
if ans:
	print('Yes')
else:
	print('No')


from fractions import gcd
n = int(input().strip())
arr = list(map(int, input().strip().split()))
val = 0
for i in range(len(arr)):
	while arr[i] % 2 == 0:
		arr[i] //= 2
	while arr[i] % 3 == 0:
		arr[i] //= 3
print(['No', 'Yes'][len(set(arr)) == 1])


import sys
import io

def div(n):
	while n % 2 == 0:
		n //= 2
	while n % 3 == 0:
		n //= 3
	return n

def solve(n, bs):
	assert 2 <= n <= 10 ** 5
	bs = list(set(bs))
	for b in bs:
		assert 1 <= b <= 10 ** 9
	(b, rest) = (bs[0], bs[1:])
	v = div(b)
	for r in rest:
		if div(r) != v:
			return 'No'
	return 'Yes'

def getinput():

	def getint():
		return int(input())

	def getints_line():
		return list(map(int, input().split(' ')))

	def getints(n):
		return [getint() for _ in range(n)]

	def getints_lines(n):
		return [getints_line() for _ in range(n)]
	return [getint(), getints_line()]

def iosolve():
	return str(solve(*getinput()))

def main():
	if sys.stdin.isatty():
		test()
	stdin_lines = getstdin_lines()
	sys.stdin = io.StringIO('\n'.join(stdin_lines))
	if stdin_lines:
		print(iosolve())
	else:
		test()

def test():
	IO_TEST_CASES = [('4\n75 150 75 50\n            ', 'Yes\n            '), ('3\n100 150 250\n            ', 'No\n            ')]
	TEST_CASES = []
	import unittest
	import sys
	import io

	class Assert(unittest.TestCase):

		def equal(self, a, b):
			self.assertEqual(a, b)

		def float_equal(self, actual, expect, tolerance):
			self.assertTrue(expect - tolerance < actual < expect + tolerance)
	art = Assert()
	for (inputs, expect) in TEST_CASES:
		art.equal(solve(*inputs), expect)
	for (stdin, expect) in IO_TEST_CASES:
		sys.stdin = io.StringIO(stdin.strip())
		art.equal(iosolve(), expect.strip())

def getstdin_lines():
	stdin = []
	while 1:
		try:
			stdin.append(input())
		except EOFError:
			break
	return stdin
main()


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


def main():
	n = int(input())
	a = [int(br) for br in input().split()]
	hcf = a[0]
	i = 1
	while i < n:
		hcf = gcd(hcf, a[i])
		i += 1
	i = 0
	while i < n:
		b = hcf
		a[i] /= b
		while a[i] > 1 and a[i] % 2 == 0:
			a[i] /= 2
		while a[i] > 1 and a[i] % 3 == 0:
			a[i] /= 3
		if a[i] != 1:
			break
		i += 1
	if i == n:
		print('Yes')
	else:
		print('No')

def gcd(a, b):
	if a == 0:
		return b
	else:
		return gcd(b % a, a)
main()


n = int(input())
arr = list(map(int, input().split()))
for (index, value) in enumerate(arr):
	while arr[index] % 2 == 0:
		arr[index] //= 2
	while arr[index] % 3 == 0:
		arr[index] //= 3
if len(set(arr)) == 1:
	print('Yes')
else:
	print('No')


def div(a):
	while a % 2 == 0:
		a //= 2
	while a % 3 == 0:
		a //= 3
	return a
N = int(input())
A = [int(x) for x in input().split()]
prev = div(A[0])
for a in A[1:]:
	if div(a) != prev:
		print('No')
		break
else:
	print('Yes')


import fractions
n = int(input())
l = [int(i) for i in input().split()]
gcd = l[0]
for i in range(1, n):
	gcd = fractions.gcd(gcd, l[i])
while gcd % 2 == 0:
	gcd /= 2
while gcd % 3 == 0:
	gcd /= 3
ans = 'YES'
for i in range(n):
	k = l[i]
	t = 1
	t1 = 1
	while k % (2 * t) == 0:
		t = t * 2
	while k % (t1 * 3) == 0:
		t1 = t1 * 3
	if gcd * t * t1 != l[i]:
		ans = 'NO'
		break
print(ans)


class Solution:

	def __init__(self):
		self.n = int(input())
		self.a = list(map(int, input().split()))

	def solution(self):
		for i in range(self.n):
			while self.a[i] % 2 == 0:
				self.a[i] //= 2
			while self.a[i] % 3 == 0:
				self.a[i] //= 3
		for i in range(1, self.n):
			if self.a[i] != self.a[0]:
				print('No')
				return
		print('Yes')

def main():
	ob = Solution()
	ob.solution()
main()


n = int(input())
(*a,) = map(int, input().split())
for i in range(n):
	while a[i] % 2 == 0:
		a[i] /= 2
	while a[i] % 3 == 0:
		a[i] /= 3
flag = 0
for i in range(n):
	if a[i] != a[0]:
		flag = 1
		print('NO')
		break
if not flag:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
s = set(a)
x = set()
for i in s:
	while i >= 1:
		if i % 2 == 0:
			i //= 2
		elif i % 3 == 0:
			i //= 3
		else:
			x.add(i)
			break
if len(x) == 1:
	print('Yes')
else:
	print('No')


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
g = a[0]
for i in a:
	g = gcd(g, i)
b = True
for i in a:
	x = i // g
	while x % 2 == 0:
		x //= 2
	while x % 3 == 0:
		x //= 3
	if x != 1:
		b = False
		break
if b:
	print('YES')
else:
	print('NO')


a = int(input())
l = list(map(int, input().split(' ')))
k = 0
for i in range(0, a):
	while l[i] % 2 == 0:
		l[i] = l[i] / 2
	while l[i] % 3 == 0:
		l[i] = l[i] / 3
	if i != 0 and k != 1:
		if l[i] != l[0]:
			print('NO')
			k = 1
if k == 0:
	print('YES')


from sys import stdin, stdout
input = stdin.readline

def nod(a, b):
	if b == 0:
		return a
	else:
		return nod(b, a % b)

def good(a):
	while a > 1:
		if a % 2 == 0:
			a //= 2
		elif a % 3 == 0:
			a //= 3
		else:
			return False
	return True
n = int(input())
a = list(map(int, input().split()))
n = a[0]
for el in a[1:]:
	n = nod(n, el)
ans = None
if all(list(map(lambda x: good(x // n), a))):
	ans = 'Yes'
else:
	ans = 'No'
stdout.write(ans)


import math
from collections import *
import sys
from functools import reduce
import time
from itertools import groupby

def input():
	return sys.stdin.readline()

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
DIRECTIONS = [(+0, +1), (+0, -1), (+1, +0), (+1, -1)]
NEIGHBOURS = [(-1, -1), (-1, +0), (-1, +1), (+0, -1), (+1, +1), (+1, +0), (+1, -1), (+0, +1)]
CAPS_ALPHABETS = {chr(i + ord('A')): i for i in range(26)}
SMOL_ALPHABETS = {chr(i + ord('a')): i for i in range(26)}
INF = float('inf')
n = int(input())
li = get_list()
ans = []
for i in li:
	while i % 2 == 0:
		i //= 2
	while i % 3 == 0:
		i //= 3
	ans.append(i)
print('Yes' if len(set(ans)) == 1 else 'No')


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')


n = int(input())
bears = input().split()
poker = []
for i in bears:
	poker.append(int(i))
for i in range(len(poker)):
	while poker[i] % 2 == 0:
		poker[i] = poker[i] / 2
	while poker[i] % 3 == 0:
		poker[i] = poker[i] / 3
true = 'Yes'
for i in range(n - 1):
	if poker[i] != poker[i + 1]:
		true = 'No'
print(true)


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
ok = True
for i in range(1, n):
	ok &= a[i] == a[i - 1]
print('Yes' if ok else 'No')


import itertools as it
import math as mt
import collections as cc
import heapq as hp
import sys
import collections as cc
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))

def lcm(a, b):
	return a * b // mt.gcd(a, b)
(n,) = I()
l = I()
ans = l[0]
for i in range(1, n):
	ans = mt.gcd(ans, l[i])
tf = 1
for i in l:
	now = i // ans
	while now % 2 == 0:
		now //= 2
	while now % 3 == 0:
		now //= 3
	if now != 1:
		tf = 0
print('YES' if tf else 'NO')


n = int(input())
l = list(map(int, input().split()))
temp = 0
for a in l:
	while a % 2 == 0:
		a /= 2
	while a % 3 == 0:
		a /= 3
	if not temp:
		temp = a
	elif temp != a:
		print('No')
		exit()
print('Yes')


def get(n):
	while n % 2 == 0:
		n = n // 2
	while n % 3 == 0:
		n = n // 3
	return n
n = input()
x = [get(int(i)) for i in input().split()]
if len(set(x)) != 1:
	print('No')
else:
	print('Yes')


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


__author__ = 'JohnHook'
n = list(map(int, input().split()))[0]
a = list(map(int, input().split()))
for i in range(len(a)):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
if a.count(a[0]) == len(a):
	print('Yes')
else:
	print('No')


n = int(input())
line = str(input()).split()
line = [int(it) for it in line]
for i in range(len(line)):
	while line[i] % 2 == 0:
		line[i] //= 2
	while line[i] % 3 == 0:
		line[i] //= 3
if len(set(line)) == 1:
	print('Yes')
else:
	print('No')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
from collections import defaultdict

def primeFactors(n):
	out = defaultdict(lambda : 0)
	while n % 2 == 0:
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			if i != 3:
				out[i] += 1
			n = n // i
	if n > 3:
		out[n] += 1
	return out
n = int(input())
arr = list(set(map(int, input().split(' '))))
z = primeFactors(arr[0])
for i in range(1, len(arr)):
	if primeFactors(arr[i]) != z:
		print('No')
		break
else:
	print('Yes')


n = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
	(a, b) = (max(a, b), min(a, b))
	if a * b == 0:
		return a
	if a % b == 0:
		return b
	return gcd(a % b, b)
GCD = gcd(a[0], a[1])
for i in range(1, n):
	GCD = gcd(a[i], GCD)

def fn(t):
	i = 0
	while t % 2 ** i == 0:
		i += 1
	t = t // 2 ** (i - 1)
	i = 0
	while t % 3 ** i == 0:
		i += 1
	t = t // 3 ** (i - 1)
	if t == 1:
		return False
	return True

def fn1(a, GCD):
	for i in a:
		if fn(i // GCD):
			return 'NO'
	return 'YES'
print(fn1(a, GCD))


def function(x):
	while x % 2 == 0:
		x /= 2
	while x % 3 == 0:
		x /= 3
	return x
n = input()
new = []
arr = list(map(int, input().split()))
for i in arr:
	new.append(function(i))
new = sorted(new)
if new[0] == new[-1]:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
a = s.split(' ')
flag = False
for i in range(len(a)):
	a[i] = int(a[i])
	while a[i] % 2 == 0 or a[i] % 3 == 0:
		if a[i] % 2 == 0:
			a[i] = a[i] / 2
		elif a[i] % 3 == 0:
			a[i] = a[i] / 3
		else:
			break
	if i > 0 and a[i] != a[i - 1]:
		flag = True
if flag != True:
	print('Yes')
else:
	print('No')


import math
from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
n = I()
a = LI()
for i in range(n):
	while a[i] % 2 == 0:
		a[i] //= 2
	while a[i] % 3 == 0:
		a[i] //= 3
flag = 1
for i in range(n - 1):
	if a[i] != a[i + 1]:
		flag = 0
		break
if flag:
	print('Yes')
else:
	print('No')


from sys import stdin as sin, stdout as sout
from math import gcd as g
n = int(sin.readline())
l = list(map(int, sin.readline().split(' ')))
pro = l[0]
for i in range(1, n):
	pro = g(pro, l[i])
for i in range(0, n):
	p = l[i] // pro
	while p % 2 == 0:
		p /= 2
	while p % 3 == 0:
		p /= 3
	if p != 1:
		sout.write('No')
		sout.flush()
		exit(0)
		break
sout.write('Yes')
sout.flush()


import math as m
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 len(set(a)) == 1 else 'No')


n = int(input())
L = list(map(int, input().split()))
for i in range(n):
	while L[i] % 2 == 0 and L[i] > 1:
		L[i] = L[i] // 2
	while L[i] % 3 == 0 and L[i] > 1:
		L[i] = L[i] // 3
ok = 1
for i in range(1, n):
	if L[i] != L[i - 1]:
		ok = 0
		break
if ok:
	print('Yes')
else:
	print('No')


n = int(input())
lis = list(map(int, input().split()))
for (i, num) in enumerate(lis):
	while lis[i] % 2 == 0:
		lis[i] = lis[i] // 2
	while lis[i] % 3 == 0:
		lis[i] = lis[i] // 3
print('Yes') if all((x == lis[0] for x in lis)) else print('No')


trash = input()
line1 = [int(x) for x in input().split()]
for i in range(0, len(line1)):
	while line1[i] % 2 == 0:
		line1[i] /= 2
	while line1[i] % 3 == 0:
		line1[i] /= 3
if min(line1) == max(line1):
	print('Yes')
else:
	print('No')


n = int(input())

def red(x):
	while x % 2 == 0:
		x //= 2
	while x % 3 == 0:
		x //= 3
	return x
i = map(int, input().split())
l = len(set(map(red, i)))
print(('NO', 'YES')[l == 1])


q = []

def pf(n):
	while n % 2 == 0 or n % 3 == 0:
		if n % 2 == 0:
			n = n // 2
		else:
			n = n // 3
	q.append(n)
p = int(input())
a = list(map(int, input().split()))
for i in range(p):
	pf(a[i])
if q.count(q[0]) == p:
	print('YES')
else:
	print('NO')


import math
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	while True:
		if a[i] % 2 == 0:
			a[i] //= 2
		elif a[i] % 3 == 0:
			a[i] //= 3
		else:
			break
if max(a) == min(a):
	print('YES')
else:
	print('NO')