n, k = map(int, input().split()) A = list(map(int, input().split())) x = 0 for a in A: x ^= a A.append(x) k %= n+1 print(A[k-1])