import sys
N = int(input())
a = input()
list1 = list(map(int,a.split()))
flag = 0

#中間部分の処理
for i in range(1, N):

    bin_num1 = list(format(list1[i-1],"b"))
    bin_num2 = list(format(list1[1+1],"b"))
    bin_num3 = []
    le,le2 = 0,0
    ans = 0
    if len(bin_num1) <= len(bin_num2):
        le = len(bin_num1)
        le2 = len(bin_num2)
        flag = 0
    else:
        le = len(bin_num2)
        le2 = len(bin_num1)
        flag = 1

    for j in range(le):
        if (int(bin_num1[len(bin_num1)-1 - j]) + int(bin_num2[len(bin_num2)-1 - j])) == 0 or (int(bin_num1[len(bin_num1)-1 - j]) + int(bin_num2[len(bin_num2)-1 - j])) == 2 :
            bin_num3.append("0")
        else:
            bin_num3.append("1")
    if le <le2:
        if flag == 0:
            for k in range(le2-le-1 , -1,-1):
                bin_num3.append(bin_num2[k])
        elif flag == 1:
            for k in range(le2-le-1 , -1,-1):
                bin_num3.append(bin_num1[k])

    bin_num3.reverse()

    ans = int("".join(bin_num3) ,2)

    if ans != int(list1[i]):
        print("No")
        sys.exit()

#最初の部分の処理

bin_num1 = list(format(list1[N-1],"b"))
bin_num2 = list(format(list1[1],"b"))
bin_num3 = []
le = 0
le2 = 0
ans = 0
if len(bin_num1) <= len(bin_num2):
    le = len(bin_num1)
    le2 = len(bin_num2)
    flag = 0
else:
    le = len(bin_num2)
    le2 = len(bin_num1)
    flag = 1

for i in range(le):
    if (int(bin_num1[len(bin_num1)-1 - i]) + int(bin_num2[len(bin_num2)-1 - i])) == 0 or (int(bin_num1[len(bin_num1)-1 - i]) + int(bin_num2[len(bin_num2)-1 - i])) == 2 :
        bin_num3.append("0")
    else:
        bin_num3.append("1")
if le <le2:
    if flag == 0:
        for k in range(le2-le-1 , -1,-1):
            bin_num3.append(bin_num2[k])
    elif flag == 1:
        for k in range(le2-le-1 , -1,-1):
            bin_num3.append(bin_num1[k])


bin_num3.reverse()
ans = int("".join(bin_num3) ,2)

if ans != list1[0]:
    print("No")
    sys.exit()

#最後の部分の処理

bin_num1 = list(format(list1[N-2],"b"))
bin_num2 = list(format(list1[0],"b"))
bin_num3 = []
le = 0
le2 = 0
ans = 0
if len(bin_num1) <= len(bin_num2):
    le = len(bin_num1)
    le2 = len(bin_num2)
    flag = 0
else:
    le = len(bin_num2)
    le2 = len(bin_num1)
    flag = 1

for i in range(le):
    if (int(bin_num1[len(bin_num1)-1 - i]) + int(bin_num2[len(bin_num2)-1 - i])) == 0 or (int(bin_num1[len(bin_num1)-1 - i]) + int(bin_num2[len(bin_num2)-1 - i])) == 2 :
        bin_num3.append("0")
    else:
        bin_num3.append("1")
if le <le2:
    if flag == 0:
        for k in range(le2-le-1 , -1,-1):
            bin_num3.append(bin_num2[k])
    elif flag == 1:
        for k in range(le2-le-1 , -1,-1):
            bin_num3.append(bin_num1[k])


bin_num3.reverse()
ans = int("".join(bin_num3) ,2)

if ans != list1[N-1]:
    print("No")
    sys.exit()
"""
for i in range(N):
    if i == 0 and i +2 == 0:
        print("Yes")
        sys.exit()
"""
#一回も引っかからなければこれで終わり
print("Yes")