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

A.insert(0, A[-1])
A.append(A[1])
answer = 'Yes'
for n in range(1, N+1):
    if (bin(A[n]) != bin(A[n-1] ^ A[n+1])):
        answer = 'No'

print(answer)