N = int(input())
A = list(map(int, input().split()))
A.append(A[0])
A.append(A[1])
for i in range(1, N + 1) :
  X = list(bin(A[i - 1]))
  Y = list(bin(A[i + 1]))
  di = abs(len(X) - len(Y))
  if(len(X) < len(Y)) :
    for k in range(di) :
      X[2 : 2] = ["0"]
  elif(len(X) > len(Y)) :
    for k in range(di) :
      Y[2 : 2] = ["0"]
  else :
    pass
  C = list()
  for j in range(max(len(X), len(Y)) - 1, 1, -1) :
    if((X[j] == "0" and Y[j] == "1") or (X[j] == "1" and Y[j] == "0")) :
      C.append("1")
    else :
      C.append("0")
  C = C[::-1]
  c = "".join(C)
  c = int(c, 2)
  if(c != A[i]) :
    print("No")
    break
  elif(i == N) :
    print("Yes")
    break
  else :
    pass
    
    