The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0<=A[i]<2^64), such that every two adjacent integers have exactly one different digit in their binary representation, similar to the Gray code.
Your task is to check whether there exist 4 numbers A[i1], A[i2], A[i3], A[i4] (1 <= i1 < i2 < i3 < i4 <= n) out of the given n numbers such that A[i1] xor A[i2] xor A[i3] xor A[i4] = 0. Here xor is a bitwise operation which is same as ^ in C, C++, Java and xor in Pascal.
-----Input-----
First line contains one integer n (4<=n<=100000).
Second line contains n space seperated non-negative integers denoting the sequence A.
-----Output-----
Output “Yes” (quotes exclusive) if there exist four distinct indices i1, i2, i3, i4 such that A[i1] xor A[i2] xor A[i3] xor A[i4] = 0. Otherwise, output "No" (quotes exclusive) please.
-----Example-----
Input:
5
1 0 2 3 7
Output:
Yes
n = int(input())
s = input()
s = s.split()
d = {}
flag = "No"

two,four = 0,0
for i in s:
 if i in d:
  d[i] += 1;
  if d[i] == 2:
   two += 1
  elif d[i] == 4:
   four += 1
 else:
  d[i] = 1;

if two>1 or four>0:
 flag = "Yes"
else:
 for i in range(n-1):
  ex = int(s[i]) ^ int(s[i+1])
  if ex in d:
   d[ex].append(i)
   if d[ex][-1] - d[ex][0] > 1:
    flag = "Yes"
    break;  
  else:
   d[ex] = [i]
print(flag)

n = int(input())
s = input()
s = s.split()
d = {}
flag = "No"

two,four = 0,0
for i in s:
 if i in d:
  d[i] += 1;
  if d[i] == 2:
   two += 1
  elif d[i] == 4:
   four += 1
 else:
  d[i] = 1;

if two>1 or four>0:
 flag = "Yes"
else:
 for i in range(n-1):
  ex = int(s[i]) ^ int(s[i+1])
  if ex in d:
   d[ex].append(i)
   if d[ex][-1] - d[ex][0] > 1:
    flag = "Yes"
    break;  
  else:
   d[ex] = [i]
print(flag)
