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