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