Overhand Shuffle


Submit solution

Points: 1
Time limit: 1.5s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python

You has been playing card games with Quinn but something seems suspicious. Quinn Keeps Wining! However, you notice Quinn's so-called "shuffling" isn't random at all! His shuffle works like this:

  • He takes the bottom card and the top card from the deck.

  • He then places them back on top of the deck in that same order (bottom card on deck then the top card is place ontop of it)

  • He repeats this process X times.

You want to figure out which card ends up at position K from the top after Quinn's shuffling, so you can finally beat him!

Input

The first line contains three integers n, x, and k — the number of cards in the deck, the number of shuffles, and the position from the top to check after shuffling (1 \leq n \leq 1000,\ 1 \leq x \leq 1000,\ 0 \leq k \leq n-1).

The second line contains n space-separated integers a_1, a_2, \dots, a_n (1 \leq a_i \leq 10^9) — the initial cards from top to bottom of the deck.

It is guaranteed that all a_i are distinct.

Output

Output the card that is k from the top (0 is the top card)

Example

Input 1
5 2 2 
1 2 3 4 5
Output 1
5
Input 2
1 10 0
5
Output 2
5

Comments

There are no comments at the moment.