n = int(input())
hats = [int(x) for x in input().split()]
hats.append(hats[0])
hats.append(hats[1])

ans = 'Yes'
for i in range(1, n + 1):
    if hats[i - 1] ^ hats[i + 1] != hats[i]:
        ans = 'No'
        break


print(ans)