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

xorNeighbor = 0
for i in range(1, len(a)-1):
    xorNeighbor += ((a[i-1] ^ a[i] ^ a[i+1]) != 0)

if xorNeighbor:
    print("No")
else:
    print("Yes")