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