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

for i in range(len(a)):
    if i == 0:
        if not bin(a[-1] ^ a[1]) == bin(a[i]):
            print('No')
            break
    elif i == len(a)-1:
        if bin(a[0]^ a[-2]) == bin(a[i]):
            print('Yes')
            break
        else:
            print('No')
            break
    else:
        if not bin(a[i-1] ^ a[i+1]) == bin(a[i]):
            print('No')
            break