import math

def check(A, N) :
  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 :0
        C.append("")
    C = C[::-1]
    c = "".join(C)
    c = int(c, 2)
    if(c != A[i]) :
      return 0    # No
    elif(i == N) :
      return 1    # Yes
      break
    else :
      pass

N = int(input())
A = list(map(int, input().split()))
B = A
B.append(B[0])
B.append(B[1])
if(check(B, N) == 1) :
  print(Yes)
else :
  for i in range(math.factorial(N)) :
    C = A.shuffle()
    C.append(C[0])
    C.append(C[1])
    if(check(C, N) == 1) :
      print(Yes)
      break
    elif(i == math.factorial - 1) :
      print("No")
      break
    else :
      pass