12151215 SUSTech Online Judge
Problem 1215 --Magic Sequences

1215: Magic Sequences

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 704  Solved: 235
[Submit][Status][Web Board]

Description

IceRuler has a sequence A = [a1,a2,...,an]. With a magic number m, he wants you to tell him the maximum element in these intervals [a1,..am], [a2,...am+1],...[an-m+1,...,an].

Input

The first line is the magic number m. The second line contains n integers, where the i-th integer repersents the integer ai. Input ends with a number -1. Constraints: 1 ≤ m < n 1 ≤ n ≤ 2000000 0 ≤ ai ≤ 1000000000

Output

Print one integer K in one line, represents the XOR sum of the maxmium elements in a[i]..a[i +m-1]s. K = the max number in [a1,..am] ⊕ the max number in [a2,..am+1] .......⊕ the max number in [an-m+1,..an]. ⊕ is the bit operation exclusive OR.

Sample Input

5
121 123 122 13 12 12 52 2 6 7 32 7 324 34 124 213 214 1412 -1

Sample Output

1178

HINT

Easy pro.

Source

 

[Submit][Status]