Queue Element FinderEasy

Queue Element Finder

EasyPractice library · +10 XPqueuesimulation

You are given a sequence of integers representing the initial state of a queue. You are also given an integer K. Your task is to find the K-th element that would be dequeued from this queue. The queue follows the First-In, First-Out (FIFO) principle. Assume the input sequence is given in the order elements are enqueued. The first element enqueued is considered the 1st element. You should not modify the original queue.

Input

The first line contains an integer N, the number of elements in the initial queue. The second line contains N space-separated integers, representing the elements of the queue from front to back. The third line contains an integer K.

Output

Print a single integer, the K-th element that would be dequeued.

Constraints

1 <= N <= 1000, 1 <= K <= N. Each element of the queue is an integer between -1000 and 1000.

Time limit 1 s (native code; slower languages get more)Memory 256 MB12 hidden tests

Example 1

Input
5
10 20 30 40 50
3
Output
30

The 3rd element to be dequeued is 30.

Example 2

Input
7
1 2 3 4 5 6 7
1
Output
1

The 1st element to be dequeued is 1.

Hints