N=int(input())
A=list(map(int,input().split()))
arr=[]
for i in range(0,N+1):
    LF=(i-1)%N if (i-1) > (N-1) else (i-1)
    RI=(i+1)%N if (i+1) > (N-1) else (i+1)
    MI=i%N if i > (N-1) else i
    aaa = str(int(bin(A[LF]).split("b")[1])+int(bin(A[RI]).split("b")[1]))
    bbb = "".join(list(map(lambda x:str(int(x)%2),aaa)))
    arr.append(int(bbb)==int(bin(A[MI]).split("b")[1]))

print("Yes" if all(arr[1:N+1]) else "No")