import copy

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

g0 = []
g1 = []
g_tmp = []
cnt_g = 0

if n % 3 != 0:
    if all((a[i] == 0 for i in range(n))):
        print('Yes')
    else:
        print('No')
else:
    while True:
        cnt = 0
        if all((a[i] == 0 for i in range(n))):
            print('Yes')
            exit()
        for i in range(n):
            if a[i] % 2 == 0:
                cnt += 1
                if cnt_g == 0:
                    g0.append(i)
                else:
                    g_tmp.append(i)
            a[i] //= 2
        if cnt * 3 != n:
            print('No')
            exit()
        if cnt_g == 0:
            cnt_g += 1
        elif cnt_g == 1:
            if g0 == g_tmp:
                pass
            else:
                g1 = copy.copy(g_tmp)
                cnt_g += 1
        else:
            if g0 == g_tmp:
                pass
            elif g1 == g_tmp:
                pass
            else:
                print('No')
                exit()
