The R1 company wants to hold a web search championship. There were n computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly affects the result. The higher the speed of the Internet is, the faster the participant will find the necessary information. Therefore, before the competition started, each computer had its maximum possible data transfer speed measured. On the i-th computer it was a_{i} kilobits per second.

There will be k participants competing in the championship, each should get a separate computer. The organizing company does not want any of the participants to have an advantage over the others, so they want to provide the same data transfer speed to each participant's computer. Also, the organizers want to create the most comfortable conditions for the participants, so the data transfer speed on the participants' computers should be as large as possible.

The network settings of the R1 company has a special option that lets you to cut the initial maximum data transfer speed of any computer to any lower speed. How should the R1 company configure the network using the described option so that at least k of n computers had the same data transfer speed and the data transfer speed on these computers was as large as possible?


-----Input-----

The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 100) — the number of computers and the number of participants, respectively. In the second line you have a space-separated sequence consisting of n integers: a_1, a_2, ..., a_{n} (16 ≤ a_{i} ≤ 32768); number a_{i} denotes the maximum data transfer speed on the i-th computer.


-----Output-----

Print a single integer — the maximum Internet speed value. It is guaranteed that the answer to the problem is always an integer.


-----Examples-----
Input
3 2
40 20 30

Output
30

Input
6 4
100 20 40 20 50 50

Output
40



-----Note-----

In the first test case the organizers can cut the first computer's speed to 30 kilobits. Then two computers (the first and the third one) will have the same speed of 30 kilobits. They should be used as the participants' computers. This answer is optimal.

Difficulty: EASY
Tags: Sorting

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))[::-1]
print(a[k - 1])


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=True)
print(L[k - 1])


(n, k) = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse=True)
print(l[k - 1])


a = lambda : list(map(int, input().strip().split()))
(n, k) = a()
s = a()
s.sort()
print(s[-k])


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(l[n - k])


(n, k) = map(int, input().split())
speeds = list(map(int, input().split()))
speeds.sort()
topSpeeds = speeds[n - k:n]
print(min(topSpeeds))


def check(mid, n, k, p):
	r = {}
	for i in p:
		if i > mid:
			i = mid
		if r.get(i) is None:
			r[i] = 1
		else:
			r[i] += 1
	for (key, value) in r.items():
		if value >= k and key >= mid:
			return key
	return

def binsearch(n, k, p):
	l = min(p)
	r = max(p) + 1
	while r - l > 1:
		mid = (r + l) // 2
		if check(mid, n, k, p) is not None:
			l = mid
		else:
			r = mid
	return l

def main():
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	print(binsearch(n, k, p))
main()


(C, N) = map(int, input().split())
PCs = list(map(int, input().split()))
PCs.sort(reverse=True)
print(PCs[N - 1])


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
(nb_computer, nb_user) = read_ints()
speeds = read_ints()
print(sorted(speeds)[-1 * nb_user])


import sys
(n, k) = map(int, input().split())
arr = sorted(list(map(int, input().split())))
print(arr[n - k])


nk = list(map(int, input().split()))
speeds = list(map(int, input().split()))
minimum = nk[0] - nk[1]
speeds.sort()
print(speeds[minimum])


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.reverse()
print(a[k - 1])


(n, k) = [int(i) for i in input().split()]
l1 = list(map(int, input().strip().split()))
l1.sort()
print(l1[n - k])


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = list(reversed(sorted(arr)))
res = []
for i in range(k):
	res.append(arr[i])
print(min(res))


(n, k) = map(int, input().split())
a = [int(s) for s in input().split()]
a = sorted(a)
print(a[n - k])


(N, K) = list(map(int, input().split()))
Speeds = list(map(int, input().split()))
Speeds.sort()
print(Speeds[-K])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
print(min(a[-k:]))


(n, m) = [int(j) for j in input().split()]
speed = sorted([int(j) for j in input().split()])
print(speed[n - m])


(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
lis.sort()
lis.reverse()
print(lis[k - 1])


(n, k) = [int(x) for x in input().split()]
list1 = [int(x) for x in input().split()]
list1.sort(reverse=True)
print(list1[k - 1])


(n, k) = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
x.sort(reverse=True)
x = x[:k]
print(min(x))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(min(l[-m:]))


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
mini = 0
b = []
for i in range(n - 1, n - k - 1, -1):
	b.append(a[i])
b.sort()
print(b[0])


(n, k) = input().split()
n = int(n)
k = int(k)
i = 0
a = list(input().split())
o = []
for s in a:
	s = int(s)
	o.append(s)
o.sort()
o.reverse()
print(o[k - 1])


(n, k) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
a.sort()
print(a[-k])


(n, k) = [int(i) for i in input().split()]
print(sorted((int(i) for i in input().split()))[-k])


import re
import inspect
from sys import argv, exit

def rstr():
	return input()

def rstrs(splitchar=' '):
	return [i for i in input().split(splitchar)]

def rint():
	return int(input())

def rints(splitchar=' '):
	return [int(i) for i in rstrs(splitchar)]

def varnames(obj, namespace=globals()):
	return [name for name in namespace if namespace[name] is obj]

def pvar(var, override=False):
	prnt(varnames(var), var)

def prnt(*args, override=False):
	if '-v' in argv or override:
		print(*args)
(c, p) = rints()
comps = sorted(rints(), key=lambda k: -1 * k)
print(comps[p - 1])


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
print(A[-k])


R = lambda : map(int, input().split())
(n, k) = R()
print(sorted(R())[-k])


added_test = input('')
test_index = input('')
l_reverse = []
l = list(map(int, test_index.split(' ')))
k = list(map(int, added_test.split(' ')))
l_new = sorted(l)
l_new.reverse()
index = k[1] - 1
print(l_new[index])


__author__ = 'Lipen'

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	print(a[k - 1])
main()


(n, k) = list(map(int, input().split()))
lst = sorted(list(map(int, input().split())))
print(lst[-k])


(n, k) = map(int, input().split())
list = [int(i) for i in input().split()]
list.sort(reverse=True)
print(list[k - 1])


(a, b) = map(int, input().split())
l = sorted(map(int, input().split()))
print(l[-b])


from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil

def st():
	return list(stdin.readline().strip())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def inp():
	return int(stdin.readline())

def pr(n):
	return stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	(n, k) = mp()
	l = li()
	l.sort()
	print(l[-k])
for _ in range(1):
	solve()


nk = input().split()
n = int(nk[0])
k = int(nk[1])
a = sorted([int(i) for i in input().split()])
print(a[n - k])


(n, k) = map(int, input().split())
ai = list(map(int, input().split()))
ai.sort()
print(ai[n - k])


import heapq
(n, uch) = list(map(int, input().split()))
speeds = list(map(int, input().split()))
godnie = heapq.nlargest(uch, speeds)
print(min(godnie))


import sys, math, cmath, time
start_time = time.time()
tt = 0

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def solve():
	(n, k) = invr()
	a = inlt()
	a.sort()
	print(a[n - k])

def main():
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
	sys.stdout.close()

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
print(sorted(a)[-k])


(n, k) = list(map(int, input().split(' ')))
print(min(sorted(list(map(int, input().split(' '))), reverse=True)[:k]))


def main():
	(n, k) = map(int, input().split(' '))
	ip = [int(item) for item in input().split(' ')]
	ip.sort()
	print(ip[len(ip) - k])
main()


arr = list(map(int, input().split()))
(n, k) = (arr[0], arr[1])
a = sorted(list(map(int, input().split())), reverse=True)
print(a[k - 1])


def rez(lst, k):
	return lst[len(lst) - k]
(N, K) = [int(i) for i in input().split()]
a = [int(j) for j in input().split()]
print(rez(sorted(a), K))


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
l.reverse()
print(l[b - 1])


def main():
	ip1 = input().split()
	ip2 = map(int, input().split())
	print(min(sorted(ip2, reverse=True)[:int(ip1[1])]))
main()


import sys
import math
import itertools
import collections

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ''.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base=3):
	newnumber = ''
	while number > 0:
		newnumber = str(number % base) + newnumber
		number //= base
	return newnumber
(n, k) = mi()
a = li()
a.sort(reverse=True)
print(a[k - 1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))[:n]
a.sort(reverse=True)
print(min(a[:k]))


(computer_num, participants_num) = map(int, input().split())
speeds = sorted(list(map(int, input().split())), reverse=True)
print(speeds[participants_num - 1])


from collections import deque
from collections import OrderedDict
import math
import sys
import os
from io import BytesIO
import threading
import bisect
import heapq
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, k) = map(int, input().split())
ar = list(map(int, input().split()))
ar.sort()
ar.reverse()
print(ar[k - 1])


(n, k) = list(map(int, input().split()))
print(list(reversed(list(sorted(list(map(int, input().split()))))))[k - 1])


s = input()
a = s.split(' ')
n = int(a[0])
t = int(a[1])
s = input()
a = s.split(' ')
for i in range(len(a)):
	a[i] = int(a[i])
a.sort()
print(a[n - t])


R = lambda : list(map(int, input().split()))
(n, m) = R()
l = sorted(R())
print(l[n - m])


(n, m) = [int(d) for d in input().split(' ')]
a = sorted([int(c) for c in input().split(' ')], reverse=True)
for i in range(len(a)):
	if i + 1 == m:
		print(a[i])
		break


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
print(min(arr[:m]))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
x = n - k
print(a[x])


nk = input().split()
n = int(nk[0])
k = int(nk[1])
M = list(map(int, input().split()))
M.sort()
print(M[-k])


line = input()
(cmp_count, parti) = line.split()
(cmp_count, parti) = (int(cmp_count), int(parti))
line = input()
a = [int(i) for i in line.split()]
a.sort()
print(a[cmp_count - parti])


x = input()
x = x.split()
n = int(x[0])
k = int(x[1])
l = input()
l = l.split()
s = []
for i in range(n):
	s.append(int(l[i]))
s.sort()
print(s[n - k])


nk = input().split()
arr = arr = map(int, input().rstrip().split())
n = int(nk[0])
k = int(nk[1])
arr = sorted(arr, reverse=True)
print(arr[k - 1])


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
if a - b != 0:
	for x in range(a - b):
		c.pop(0)
print(c[0])


def main():
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	print(A[k - 1])
main()


(k, n) = input().split()
k = int(k)
n = int(n)
a = input().split()
a = [int(item) for item in a]
a.sort()
a.reverse()
a = a[0:n]
print(min(a))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(l[-1 * m])


cnt = lambda s, i: s.count(i)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
(n, k) = f()
l = il()
l.sort(reverse=True)
print(l[k - 1])


I = lambda : map(int, input().split())
(_, k) = I()
print(sorted(I())[-k])


k = int(input().split()[1])
s = list(map(int, input().split()))
s.sort(reverse=True)
print(s[k - 1])


X = list(map(int, input().split()))
print(sorted(list(map(int, input().split())), reverse=True)[X[1] - 1])


(n, k) = map(int, input().split())
S = sorted(list(map(int, input().split())))
maxim = S[-1 * k]
print(maxim)


from heapq import nlargest
I = lambda : map(int, input().split())
(n, k) = I()
print(nlargest(k, list(I()))[k - 1])
print(exit())


from collections import Counter
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
count = Counter(arr)
sor = sorted(count.items(), key=lambda x: x[0], reverse=True)
for (i, j) in sor:
	k -= j
	if k < 1:
		print(i)
		break


def main():
	[n, k] = [int(_) for _ in input().split()]
	speeds = [int(_) for _ in input().split()]
	speeds.sort(reverse=True)
	print(speeds[k - 1])
main()


def main():
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))[::-1]
	print(a[k - 1])
	return
main()


(n, k) = map(int, input().split())
print(sorted(map(int, input().split()))[-k])


k = int(input().split()[1])
a = sorted(map(int, input().split()))
print(a[-k])


b = input().split()
n = int(b[0])
k = int(b[1])
a = input().split()
ai = []
for i in range(n):
	ai.append(int(a[i]))
ai.sort()
print(ai[n - k])


I = lambda : map(int, input().split())
(n, k) = I()
print(sorted(I())[n - k])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(set(a))
b.sort()
count = []
c = 0
for j in range(len(b)):
	z = b[j]
	c = 0
	for i in range(len(a)):
		if a[i] >= z:
			c = c + 1
	count.append(abs(c - k))
print(b[count.index(min(count))])


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	(n, k) = idata()
	data = sorted(idata())
	print(data[-k])
	return
for t in range(1):
	solve()


(n, k) = map(int, input().split())
data = list(map(int, input().split()))
line = [0] * n
maxx = 0
for i in range(n):
	count = 0
	for j in range(n):
		if data[i] <= data[j]:
			count += 1
	line[i] = count
	if count >= k:
		maxx = max(maxx, data[i])
print(maxx)


(a, b) = map(int, input().split())
f = list(map(int, input().split()))
c = []
while b != 0:
	c.append(max(f))
	del f[f.index(max(f))]
	b -= 1
print(min(c))


(_, k) = [int(x) for x in input().split()]
print(sorted([int(x) for x in input().split()], reverse=True)[k - 1])


l1 = [int(x) for x in input().split()]
(n, k) = (l1[0], l1[1])
l2 = [int(x) for x in input().split()]
l2.sort(reverse=True)
print(l2[k - 1])


(n, k) = map(int, input().split())
A = sorted(list(map(int, input().split())))
print(A[n - k])


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
s = list(sorted(s))
print(min(s[n - k:]))


def maximum_s(n, k, a):
	a = sorted(a)
	a = a[::-1]
	a = a[:k]
	return min(a)
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
print(maximum_s(n, k, a))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
print(a[n - 1 - k + 1])


import sys
line = str.split(input(), ' ')
n = int(line[0])
k = int(line[1])
line = str.split(str(input()), ' ')
speeds = []
for s in line:
	speeds.append(int(s))
sspeeds = speeds
sspeeds.sort()
sspeeds.reverse()
sys.stdout.write(str(sspeeds[k - 1]))


(a, b) = map(int, input().split())
r = lambda : list(map(int, input().split()))
arr = r()
arr.sort(reverse=True)
print(min(arr[:b]))


(n, k) = list(map(int, input().split()))
s = list(map(int, input().split()))
s.sort()
print(s[-k])


(n, k) = list(map(int, input().split()))
t = list(map(int, input().split()))
t.sort()
s = t[::-1]
print(s[k - 1])


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
arr = arr[::-1]
for i in range(n):
	if i + 1 == k:
		print(arr[i])
		break


([n, k], speed) = (map(int, input().split()), sorted(map(int, input().split()), reverse=True))
print(speed[k - 1])


def convert(arr):
	arr = arr.split(' ')
	for i in range(len(arr)):
		arr[i] = int(arr[i])
	return arr
ap = input()
s = input()
nums = convert(ap)
netSpeed = convert(s)
netSpeed.sort(reverse=True)
print(netSpeed[nums[1] - 1])