831. Kth Largest Element in an Array

0

Medium

Given an array A of integers and an integer k, find and print the kth largest element in the array.
Note that the kth largest element refers to its position in the sorted order, not the kth distinct element.

Input Format

The first line contains two space-separated integers N (the size of the array) and K.

The second line contains the elements of the array, separated by spaces.

The second line contains the elements of the array, separated by spaces.

Output Format

Print the kth largest element of the array.

Example

Input

6 2
4 6 2 7 9 1

Output

7

Constraints

1 <= N <= 10^4

1 <= k <= N

-10^5 <= Arr[i] <= 10^5

1 <= k <= N

-10^5 <= Arr[i] <= 10^5

Loading...

View Submissions

Console