N = int(input())
numbers = input().split()
circle = True

leftNumber = int(numbers[-1])
currentNumber = int(numbers[0])
rightNumber = int(numbers[1])
if currentNumber != leftNumber ^ rightNumber:
  circle = False

for i in range(N-2):
  leftNumber = int(numbers[i-1])
  currentNumber = int(numbers[i])
  rightNumber = int(numbers[i+1])
  if currentNumber != leftNumber ^ rightNumber:
    circle = False
    
leftNumber = int(numbers[N-2])
currentNumber = int(numbers[N-1])
rightNumber = int(numbers[0])
if currentNumber != leftNumber ^ rightNumber:
  circle = False
  
if circle == False:
  print("No")
else:
  print("Yes")