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

for n in range(0, N):
    if 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])
        # XOR回路
        if bin(Flontstr ^ Afterstr) != bin(binstr):
            flag=1
            print('No')
            break
    elif int(n)==N-1 and flag==0:
        print('Yes')
        
        



