N, K = gets.split.map(&:to_i) A = gets.split.map(&:to_i) A << A.inject(:^) puts A[(K - 1) % (N + 1)]