a = int(input())
b = list(map(int, input().split()))
b.insert(0, b[len(b)-1])
b.append(b[1])
for i in range(1, len(b)-1):
    if b[i-1] ^ b[i+1] != b[i] ^ 0:
        print("No")
        exit()
print("Yes")
