
def logicalsum_str(a, b):
    La = len(a)
    Lb = len(b)
    ans = ""
    if La >= Lb:
        for i in range(Lb):
            if a[-(1 + i)] == b[-(1 + i)]:
                ans = "0" + ans
            else:
                ans = "1" + ans
        ans = a[0:La-Lb] + ans
    else:
        for i in range(La):
            if a[-(1 + i)] == b[-(1 + i)]:
                ans = "0" + ans
            else:
                ans = "1" + ans
        ans = a[0:Lb-La] + ans

    return ans

N=int(input())
A=list(map(int,input().split()))
B=[""]*N
for i in range(N):
    temp=A[i]
    if temp==0:
        B[i]="0"
    while temp>0:
        B[i]=str(temp%2)+B[i]
        temp=temp//2

if int(B[0])!=int(logicalsum_str(B[-1],B[1])) or  int(B[-1])!=int(logicalsum_str(B[-2],B[0])):
    print("No")
    exit()

for i in range(2,N-1):
    if int(B[i])!=int(logicalsum_str(B[i-1],B[i+1])):
        print("No")
        exit()

print("Yes")

