N = int(input())
Rakuda_data =  input().split(' ')
flag = 0

for n in range(0, N):
    if 0 == int(n):
        Flontstr = int(Rakuda_data[N-1])
        binstr = int(Rakuda_data[0])
        Afterstr = int(Rakuda_data[1])
    elif 0 < int(n) and int(n) < N-1:
        Flontstr = int(Rakuda_data[n-2])
        binstr = int(Rakuda_data[n-1])
        Afterstr = int(Rakuda_data[n])
    elif N-1==int(n):
        Flontstr = int(Rakuda_data[N-2])
        binstr = int(Rakuda_data[N-1])
        Afterstr = int(Rakuda_data[0])
        
        
    # XOR回路
    if bin(Flontstr ^ Afterstr) != bin(binstr):
        flag=1
        print('No')
        break
    
    if int(n)==N-1 and flag==0:
        print('Yes')
        
        



