n = int(input())
a = list(map(int, input().split()))
A = a + a
for i in range(n):
    x1 = A[i - 1]
    x2 = A[i + 1]
    if bin(x1 ^ x2) != bin(a[i]):
        print("No")
        exit()
print("Yes")
