N, K = map(int, input().split()) A = list(map(int, input().split())) v = 0 for a in A: v ^= a A = [v] + A K %= N + 1 print(A[K])