Cipher

Time Limit: 1 Second    Memory Limit: 32768 KB

The village of Martyshkino was fortunate to hold the 1/256-final of the world championship in computer programming. The General Organizer of the championship (who was also The Jury Chairman) decided that no precautions are excessive and ciphered all secret tests by repeatedly intermixing them. In order to make the cipher stronger he did the mixing as many times, as many numbers were in the test. We should note, that all the numbers were natural and complied with the condition: 1 <= Xi <= N, where N is the amount of numbers in the test.

The mixing procedure consisted of the following. The initial or the resulting after the previous mixing sequence was split into two groups. The size of the first group was defined by the value of the first number of the current sequence, the second (maybe empty) group included all the remaining numbers. After that there were three steps: writing the numbers of the first group in the back order, writing the numbers of the second group in the back order, writing the numbers of the whole sequence in the back order.

It's obvious that after executing N procedures of such a brilliant mixing no spy would be able to restore the secret test (except for the General Organizer, of course). Your task is slightly easier: you need to find the first member of the sequence after it has been ciphered.

1 <= n <= 61099

Input

The first line of the input file contains the number N and all the following lines (there may be several of them) contain N elements of a numeral sequence, separated by one or several spaces.

Process to the end of file.

Output

The output file must contain the solution: the first element of the sequence after mixing it.

Sample Input

4
2 4 1 1

Sample Output

1
Submit