N = int(input())
a = list(map(int, input().split()))
b = len(a)
a.append(a[0])
a.append(a[1])
c = 0
if max(a) == 0:
  print('Yes')
else:
  for i in range(b-1):
    if a[i]^a[i+1]^a[i+2] == 0 and a[i+1]^a[i+2]^a[i+3] == 0:
      c += 1
  if c != 0:
    print('Yes')
  else:
    print('No')