N = int(input())
a = list(map(int ,input().split()))
a.extend(a[:3])

ans = 'Yes'
for x in range(N+1):
    if int(bin(a[x]^a[x+2]), 0) != a[x+1]:
        ans = 'No'
        break
print(ans)            