Nth Smallest ElementEasy

Nth Smallest Element

EasyPractice library · +10 XPheapssortingselection

Given a list of N integers, find and print the N-th smallest element. The input list may contain duplicate values. The elements are 1-indexed, so the 1st smallest is the minimum element, the 2nd smallest is the next smallest, and so on.

Input

The first line contains an integer N. The second line contains N space-separated integers.

Output

Print a single integer: the N-th smallest element.

Constraints

1 <= N <= 1000 -10^9 <= element <= 10^9

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

Example 1

Input
5
1 5 2 3 4
Output
5

N=5, list is [1, 5, 2, 3, 4]. Sorted: [1, 2, 3, 4, 5]. The 5th smallest is 5.

Example 2

Input
3
10 10 20
Output
20

N=3, list is [10, 10, 20]. Sorted: [10, 10, 20]. The 3rd smallest is 20.

Hints