You are given a sequence of integers of length $n$ and integer number $k$. You should print any integer number $x$ in the range of $[1; 10^9]$ (i.e. $1 \le x \le 10^9$) such that exactly $k$ elements of given sequence are less than or equal to $x$.

Note that the sequence can contain equal elements.

If there is no such $x$, print "-1" (without quotes).


-----Input-----

The first line of the input contains integer numbers $n$ and $k$ ($1 \le n \le 2 \cdot 10^5$, $0 \le k \le n$). The second line of the input contains $n$ integer numbers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$) — the sequence itself.


-----Output-----

Print any integer number $x$ from range $[1; 10^9]$ such that exactly $k$ elements of given sequence is less or equal to $x$.

If there is no such $x$, print "-1" (without quotes).


-----Examples-----
Input
7 4
3 7 5 1 10 3 20

Output
6
Input
7 2
3 7 5 1 10 3 20

Output
-1



-----Note-----

In the first example $5$ is also a valid answer because the elements with indices $[1, 3, 4, 6]$ is less than or equal to $5$ and obviously less than or equal to $6$.

In the second example you cannot choose any number that only $2$ elements of the given sequence will be less than or equal to this number because $3$ elements of the given sequence will be also less than or equal to this number.

Difficulty: EASY
Tags: Sorting
Skill types: Sorting

Starter code:

Solutions:
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
if k == 0:
	if a[0] > 1:
		print(a[0] - 1)
	else:
		print(-1)
elif n == k:
	print(a[n - 1])
elif a[k] == a[k - 1]:
	print(-1)
else:
	print(a[k] - 1)


(n, k) = map(int, input().split())
a = [*map(int, input().split())]
a.sort()
if k == 0:
	if a[0] > 1:
		print(a[0] - 1)
	else:
		print(-1)
else:
	chk = a[k - 1]
	if k < n:
		if a[k] > chk:
			print(a[k - 1])
		else:
			print(-1)
	else:
		print(a[k - 1])


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
count = 0
i = 0
if k == 0:
	if a[0] != 1:
		print(1)
	else:
		print(-1)
	quit()
while i < n:
	j = i + 1
	while j < n and a[j] == a[i]:
		j += 1
	if j == k:
		print(a[i])
		quit()
	if j > k:
		break
	i = j
print(-1)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = sorted(arr)
ans = 0
if k == 0:
	ans = arr[0] - 1
else:
	ans = arr[k - 1]
count = 0
for i in range(n):
	if arr[i] <= ans:
		count += 1
f = 1
if count != k or not (1 <= ans and ans <= 1000 * 1000 * 1000):
	print(-1)
	f = 0
if f:
	print(ans)


(n, k) = map(int, input().split())
a = [int(a) for a in input().split()]
a.sort()
if k == 0:
	if a[0] > 1:
		print(1)
	else:
		print(-1)
elif k <= n - 1:
	if a[k - 1] != a[k]:
		print(a[k - 1])
	else:
		print(-1)
elif k == n:
	print(a[k - 1])


from bisect import bisect_left, bisect_right
(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = -1
for i in a:
	for j in [i - 1, i, i + 1]:
		if 1 <= j <= 10 ** 9:
			x = bisect_right(a, j)
			if x == k:
				ans = j
print(ans)


(n, k) = input().split()
(n, k) = (int(n), int(k))
arr = [int(x) for x in input().split()]
if n == k:
	print(int(1000000000.0))
else:
	arr.sort()
	if k == 0 and arr[0] == 1:
		print(-1)
	elif k == 0 and arr[0] > 1:
		print(1)
	else:
		p = arr[k - 1]
		if p == arr[k]:
			print(-1)
		else:
			print(p)


from sys import stdin
from collections import defaultdict

def main():
	(_, k) = stdin_get_ints_from_line()
	r = defaultdict(int)
	for x in stdin.readline().split(' '):
		r[int(x)] += 1
	f = 0
	for key in sorted(r):
		if k == 0 and key > 1:
			print(1)
			return
		f += r[key]
		if f == k:
			print(key)
			return
		elif f > k:
			print(-1)
			return
	print(-1)

def stdin_get_ints_from_line():
	return (int(x) for x in stdin.readline().strip().split(' '))

def stdin_get_ints_list_from_line():
	return list((int(x) for x in stdin.readline().strip().split(' ')))

def stdin_get_string_from_line():
	return stdin.readline().strip()
main()


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
s.sort()
if k != 0:
	if k != n and s[k] == s[k - 1]:
		print(-1)
	elif k == n:
		print(s[-1])
	else:
		print(s[k] - 1)
elif s[0] == 1:
	print(-1)
else:
	print(s[0] - 1)


def check(arr, x, k):
	for i in arr:
		if i <= x:
			k -= 1
	return k
(n, k) = map(int, input().split())
m = list(map(int, input().split()))
low = 1
high = int(1000000000.0)
mid = low + (high - low) // 2
while low < high:
	if check(m, mid, k) > 0:
		low = mid + 1
	elif check(m, mid, k) < 0:
		high = mid
	else:
		break
	mid = low + (high - low) // 2
if check(m, mid, k) == 0:
	print(mid)
else:
	print(-1)


(num_of_nums, k) = map(int, input().split())
list_nums = sorted(list(map(int, input().split())))
Done = False
if k == num_of_nums:
	print(list_nums[k - 1])
	Done = True
if k == 0 and Done is False:
	if list_nums[0] > 1:
		print(1)
		Done = True
	else:
		print(-1)
		Done = True
if Done is False:
	if list_nums[k - 1] < list_nums[k]:
		print(list_nums[k - 1])
	else:
		print(-1)


def main():
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a.sort()
	if k == 0 and a[0] == 1:
		print('-1')
		return
	if k == 0:
		print('1')
		return
	k -= 1
	x = a[k]
	for i in range(k + 1, n):
		if x == a[i]:
			print('-1')
			return
	print(x)
main()


a = [int(q) for q in input().strip().split()]
b = [int(q) for q in input().strip().split()]
b.sort()
if a[1] == 0:
	if b[0] >= 2:
		print(b[0] - 1)
	else:
		print(-1)
elif a[0] == a[1]:
	print(b[a[1] - 1])
elif b[a[1] - 1] != b[a[1]]:
	print(b[a[1] - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
A = list(map(int, input().split())) + [1000000001]
A.sort()
if k == 0:
	if A[0] == 1:
		print(-1)
	else:
		print(1)
elif A[k] == A[k - 1]:
	print(-1)
else:
	print(A[k - 1])


from itertools import accumulate, takewhile
from bisect import bisect_right
from collections import Counter
I = lambda : list(map(int, input().split()))
(n, k) = I()
a = I()
a.sort()
if k == 0:
	print(1 if a[0] > 1 else -1)
elif k < n and a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k - 1] if a[k - 1] <= int(1000000000.0) else -1)


(n, k) = [int(i) for i in input().split()]
lista = [int(i) for i in input().split()]
lista.sort()
if k == 0:
	if lista[0] != 1:
		print(1)
	else:
		print(-1)
elif n == k:
	print(lista[n - 1])
elif lista[k - 1] != lista[k]:
	print(lista[k - 1])
else:
	print(-1)


x = list(map(int, input().split()))
n = x[0]
k = x[1]
arr = list(map(int, input().split()))
arr.sort()
if k == 0:
	yo = arr[0] - 1
	if yo >= 1:
		print(yo)
	else:
		print(-1)
elif k == n:
	print(arr[k - 1])
else:
	p = arr[k - 1]
	q = arr[k]
	if p == q:
		print(-1)
	else:
		print(p)


from sys import stdin
(n, k) = map(int, stdin.readline().split())
arr = sorted(list(map(int, stdin.readline().split())))
if k == 0:
	if arr[0] > 1:
		print('1')
	else:
		print('-1')
elif k < n:
	if arr[k] == arr[k - 1]:
		print('-1')
	else:
		print(arr[k - 1])
elif k == n:
	print(arr[k - 1])


from sys import stdin, stdout
for _ in range(1):
	(n, k) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	a.sort()
	if k == 0:
		if 1 in a:
			print(-1)
		else:
			print(1)
		continue
	if k == n:
		print(a[-1])
		continue
	print(a[k - 1] if a[k - 1] != a[k] else -1)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
(N, K) = MAP()
A = [1] + LIST() + [INF]
A.sort()
if A[K] != A[K + 1]:
	print(A[K])
else:
	print(-1)


(n, k) = input().split(' ')
n = int(n)
k = int(k)
nums = list(map(int, input().split(' ')))
t = []
nums = sorted(nums)
if k == 0 and nums[0] == 1:
	print('-1')
elif k == 0 and nums[0] != 1:
	print(nums[k] - 1)
elif k != 0 and n != 1 and (n != k) and (nums[k - 1] == nums[k]):
	print('-1')
elif k != 0 and n != 1 and (n != k) and (nums[k - 1] != nums[k]):
	print(nums[k - 1])
elif k == 1 and n == 1:
	print(nums[0])
elif n == k:
	print(nums[k - 1])


import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = pow(10, 9) + 7

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def solve():
	(n, k) = sep()
	a = lis()
	a = sorted(a)
	if n == k:
		print(a[n - 1])
	elif k == 0:
		if a[0] > 1:
			print(1)
		else:
			print(-1)
	elif a[k] == a[k - 1]:
		print(-1)
	else:
		print(a[k - 1])
testcase(1)


(_, qtd) = map(int, input().split())
lista = list(map(int, input().split()))
lista.sort()
if qtd == 0:
	print(1) if lista[0] > 1 else print(-1)
elif len(lista) == qtd:
	print(lista[-1])
elif lista[qtd - 1] < lista[qtd]:
	print(lista[qtd - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
if k == 0:
	if a[0] - 1 <= 0:
		print(-1)
	else:
		print(a[0] - 1)
	exit()
if k < n:
	if a[k] > a[k - 1]:
		print(a[k - 1])
	else:
		print(-1)
else:
	print(a[k - 1])


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
if n == k:
	print(arr[-1])
else:
	gr = arr[k]
	le = arr[k - 1] if k > 0 else 1
	if gr != le:
		print(le)
	else:
		print(-1)


from bisect import bisect as bs
rd = lambda : list(map(int, input().split()))
(n, k) = rd()
a = sorted(rd())
if n == k:
	print(a[-1])
elif k:
	x = bs(a, a[k - 1] - 1)
	y = bs(a, a[k] - 1)
	print(-1 if x == y else a[x])
else:
	print(-1 if a[0] == 1 else 1)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
if K > N:
	print(-1)
elif K == N:
	print(max(A))
elif K == 0:
	ans = min(A) - 1
	if ans < 1:
		print(-1)
	else:
		print(ans)
else:
	A.sort()
	if A[K - 1] == A[K]:
		print(-1)
	else:
		print(A[K - 1])


(n, k) = [int(x) for x in input().split()]
numlst = [int(x) for x in input().split()]
numlst.sort()
if k == 0:
	if numlst[0] - 1 < 1 or numlst[0] - 1 > 10 ** 9:
		print('-1')
	else:
		print(numlst[0] - 1)
elif k == n:
	if numlst[n - 1] < 1 or numlst[n - 1] > 10 ** 9:
		print('-1')
	else:
		print(numlst[n - 1])
elif numlst[k - 1] == numlst[k] or numlst[k - 1] < 1 or numlst[k - 1] > 10 ** 9:
	print('-1')
else:
	print(numlst[k - 1])


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a.append(1)
a = sorted(a)
if k != n:
	if a[k] < a[k + 1]:
		print(a[k])
	else:
		print(-1)
else:
	print(a[k])


(n, k) = map(int, input().split())
a = sorted([int(_) for _ in input().split()])
a.append(10 ** 9 + 1)
if k == 0:
	if a[0] - 1 > 0:
		print(a[0] - 1)
	else:
		print(-1)
elif a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k - 1])


(n, k) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
arr.sort()
if k == 0 and arr[0] >= 2:
	print(1)
elif k == 0:
	print(-1)
elif n == k:
	print(arr[-1])
elif arr[k - 1] < arr[k] - 1:
	print(arr[k - 1] + 1)
elif arr[k - 1] != arr[k]:
	print(arr[k - 1])
else:
	print(-1)


(n, m) = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
if m == 0:
	print(-1 if A[0] == 1 else A[0] - 1)
elif m == n:
	print(A[n - 1])
elif A[m - 1] == A[m]:
	print(-1)
else:
	print(A[m - 1])


import sys
input = sys.stdin.readline

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	if k == n:
		print(10 ** 9)
	elif k == 0:
		if a[0] > 1:
			print('1')
		else:
			print('-1')
	elif a[k - 1] == a[k]:
		print('-1')
	else:
		print(a[k - 1])
main()


import sys
import itertools
import math
import collections
from collections import Counter

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

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 ceil(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 prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
(n, k) = mi()
d = sorted(li())
if k == 0 and d[0] != 1:
	print(1)
elif k != 0 and (k == n or d[k - 1] != d[k]):
	print(d[k - 1])
else:
	print(-1)


user_input = input().split(' ')
n = int(user_input[0])
k = int(user_input[1])
user_input_list = input().split(' ')
counter = 0
int_list = []
for elements in user_input_list:
	int_list.append(int(elements))
int_list.sort()
if k > 0:
	x = int_list[k - 1]
else:
	x = 1
if len(int_list) > k and int_list[k - 1] <= 1000000000:
	if int_list[k] != x:
		print(x)
	elif int_list[k] != x and int_list[k] > 1:
		print(int_list[k] - 1)
	else:
		print(-1)
else:
	print(int_list[k - 1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if k == 0 and a[0] == 1:
	print(-1)
elif k == 0 and a[0] > 1:
	print(a[0] - 1)
elif n < 3 and k > 0:
	if n == 1 and k == 1:
		print(a[0])
	elif n == 2 and k == 1:
		if a[0] == a[1]:
			print(-1)
		else:
			print(a[0])
	elif n == 2 and k == 2:
		print(a[1])
elif k == n:
	print(a[-1])
else:
	flag = 0
	if a[k - 1] != a[k]:
		flag = a[k - 1]
	print(flag if flag != 0 else -1)


(n, k) = [int(x) for x in input().split()]
a = [1] + [int(x) for x in input().split()]
a.sort()
if k == n or a[k] != a[k + 1]:
	print(a[k])
else:
	print(-1)


from bisect import bisect
(n, k) = map(int, input().split())
A = sorted(map(int, input().split()))
x = 1 if k == 0 else A[k - 1]
ak = bisect(A, x)
print(-1 if ak != k else x)


(n, k) = list(map(int, input().split()))
ar = list(map(int, input().split()))
ar.sort()
if k == 0:
	if ar[0] == 1:
		x = -1
	else:
		x = 1
elif k == n:
	x = ar[k - 1]
elif n > 1 and ar[k] == ar[k - 1]:
	x = -1
else:
	x = ar[k - 1]
print(x)


(a, b) = map(int, input().split())
c = dict()
for i in map(int, input().split()):
	c[i] = c.get(i, 0) + 1
j = sorted(c)
s = 0
if b != 0:
	for i in j:
		if s + c[i] > b:
			print(-1)
			exit()
		elif s + c[i] == b:
			print(i)
			exit()
		else:
			s += c[i]
	if s == b:
		print(max(j))
	else:
		print(-1)
else:
	k = min(j)
	if k != 1:
		print(1)
	else:
		print(-1)


(n, k) = [int(el) for el in input().split(' ')]
sequence = [int(el) for el in input().split(' ')]
sequence.sort()
result = -1
if n == 1:
	if k == 0:
		result = sequence[0] - 1
	else:
		result = sequence[0]
elif n == k:
	result = sequence[k - 1]
elif k == 0:
	result = sequence[0] - 1
elif sequence[k - 1] == sequence[k]:
	result = -1
else:
	result = sequence[k - 1]
if result <= 0 or result > 10 ** 9:
	result = -1
print(result)


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 1
if k == 0:
	if a[0] == 1:
		ans = -1
else:
	ans = a[k - 1]
	if k < n and a[k] == ans:
		ans = -1
print(ans)


def main():
	(n, k) = map(int, input().split())
	a = [int(e) for e in input().split()]
	a.sort()
	if k == 0:
		if a[0] == 1:
			print(-1)
		else:
			print(a[0] - 1)
	elif k == n:
		print(a[-1])
	elif a[k - 1] == a[k]:
		print(-1)
	else:
		print(a[k - 1])
main()


line = input().split()
n = int(line[0])
k = int(line[1])
line = input().split()
numbers = []
for number in line:
	numbers.append(int(number))
list.sort(numbers)
if k == n:
	print(numbers[k - 1])
elif k == 0:
	if numbers[0] == 1:
		print(-1)
	else:
		print(1)
elif numbers[k - 1] != numbers[k]:
	print(numbers[k - 1])
else:
	print(-1)


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
if len(a) == 1:
	if k != 0:
		print(a[0])
	elif a[0] == 1:
		print(-1)
	else:
		print(a[0] - 1)
elif k != 0 and k != n:
	if a[k] != a[k - 1]:
		print(a[k - 1])
	else:
		print(-1)
elif k == n:
	print(a[n - 1])
elif a[0] != 1:
	print(a[0] - 1)
else:
	print(-1)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2, floor
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 9 + 7
LOGN = 30
T = 1
for _ in range(T):
	(n, k) = list(map(int, stdin.readline().rstrip().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	a.sort()
	if k == 0:
		if a[0] == 1:
			print(-1)
		else:
			print(1)
		continue
	pos = bisect_right(a, a[k - 1])
	if pos != k:
		print(-1)
	else:
		print(a[k - 1])


def cnt(s, x):
	hi = len(s) - 1
	lo = 0
	ans = 0
	while hi >= lo:
		mid = (hi + lo) // 2
		if s[mid] <= x:
			lo = mid + 1
			ans = mid + 1
		else:
			hi = mid - 1
	return ans
(a, b) = map(int, input().split())
s = sorted(list(map(int, input().split())))
if b == 0:
	if s[0] == 1:
		print(-1)
	else:
		print(1)
	exit(0)
j = s[b - 1]
if cnt(s, j) > b:
	print(-1)
else:
	print(j)


from sys import stdin
import bisect

def bsearch(l, r, k, li):
	while l < r:
		mid = l + (r - l) // 2
		p = bisect.bisect_right(li, mid, 0, len(li))
		if p < k:
			l = mid + 1
		else:
			r = mid
	p = bisect.bisect_right(li, l, 0, len(li))
	return l if p == k else -1

def solve(tc):
	(n, k) = map(int, stdin.readline().split())
	li = list(map(int, stdin.readline().split()))
	li.sort()
	print(bsearch(1, int(1000000000.0), k, li))
	pass
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip()) if LOCAL_TEST else 1
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


(n, k) = map(int, input().split())
l = sorted(list(map(int, input().split())))
a = [1] + l
if k == n or a[k + 1] - a[k]:
	print(a[k])
else:
	print('-1')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, k) = LI()
	a = sorted(LI())
	if k == 0:
		if a[0] > 1:
			return 1
		else:
			return -1
	if n == k:
		return a[-1]
	if a[k] > a[k - 1]:
		return a[k - 1]
	return -1
print(main())


(n, k) = map(int, input().split())
lis = sorted(map(int, input().split()))
if n == 1 and k == 1:
	print(lis[0])
elif k == 0 and lis[0] == 1:
	print('-1')
elif k == 0 and lis[0] != 1:
	print(lis[0] - 1)
elif k == n:
	print(lis[-1])
elif lis[k - 1] == lis[k]:
	print('-1')
else:
	print(lis[k - 1])


(n, k) = map(int, input().split())
a = []
for s in input().split():
	a.append(int(s))
a.append(min(a) - 1)
a.append(max(a) + 1)
a.sort()
if 1 <= a[k] <= 1000000000.0 and a[k] != a[k + 1]:
	print(a[k])
else:
	print(-1)


(n, b) = list(map(int, input().split()))
s = list(map(int, input().split()))
s.sort()
if b == 0:
	if s[0] - 1 < 1:
		print(-1)
	else:
		print(s[0] - 1)
elif b == n:
	print(s[-1])
elif s[b] == s[b - 1]:
	print(-1)
else:
	print(s[b - 1])


import sys
import math
import random
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def tot(ara, k):
	cnt = 0
	for num in ara:
		if num <= mid:
			cnt += 1
	return cnt <= k
(n, k) = invr()
ara = inara()
hi = int(1000000000.0)
lo = 1
ans = -1
while hi >= lo:
	mid = (hi + lo) // 2
	cnt = 0
	for num in ara:
		if num <= mid:
			cnt += 1
	if tot(ara, k):
		ans = mid
		lo = mid + 1
	else:
		hi = mid - 1
cnt = 0
for num in ara:
	if num <= ans:
		cnt += 1
if cnt == k:
	print(ans)
else:
	print(-1)


(n, k) = map(int, input().split())
l = sorted(list(map(int, input().split()))) + [-1]
print(1 if k == 0 and l[0] != 1 else l[k - 1] if l[k - 1] != l[k] else -1)


(n, k) = map(int, input().split())
l = map(int, input().split())
l = sorted(l)
if k == 0:
	if l[0] == 1:
		print(-1)
	else:
		print(1)
elif k == n:
	print(1000000000)
elif l[k] == l[k - 1]:
	print(-1)
else:
	print(l[k - 1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
if k == 0:
	ans = a[0] - 1
else:
	ans = a[k - 1]
for i in range(n):
	if a[i] <= ans:
		cnt += 1
	else:
		break
if ans < 1 or cnt != k:
	print(-1)
else:
	print(ans)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if k == n:
	print(l[-1])
elif k == 0:
	if l[0] == 1:
		print(-1)
	else:
		print(1)
else:
	x = l[k - 1]
	if x == l[k]:
		print(-1)
	else:
		print(x)


(n, k) = map(int, input().split())
ls = list(map(int, input().split()))
ls.sort()
if len(ls) > k:
	if k == 0:
		if ls[0] - 1 >= 1:
			print(1)
		else:
			print(-1)
	elif ls[k] == ls[k - 1]:
		print('-1')
	else:
		print(ls[k - 1])
elif len(ls) == k:
	print(ls[k - 1])
else:
	print('-1')


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

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()
if n == k:
	print(a[-1])
elif k == 0 and a[0] == 1 or (a[k - 1] == a[k] and k != 0):
	print(-1)
elif k == 0 and a[0] != 1:
	print(a[0] - 1)
else:
	print(a[k - 1])


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if k == 0:
	a = l[k] - 1
else:
	a = l[k - 1]
count = 0
for i in l:
	if i <= a:
		count += 1
	if count > k:
		break
if count == k and a > 0:
	print(a)
else:
	print('-1')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if m == 0:
	ans = l[0] - 1
else:
	ans = l[m - 1]
cnt = 0
for i in range(n):
	if l[i] <= ans:
		cnt += 1
if cnt != m or not 1 <= ans:
	print(-1)
else:
	print(ans)


nk = list(map(int, input().split()))
a = list(map(int, input().split()))
n = nk[0]
k = nk[1]
a.sort()
x = -1
if k > 0:
	if k == n:
		x = a[k - 1]
	elif a[k - 1] != a[k]:
		x = a[k] - 1
elif a[k] - 1 > 0:
	x = a[k] - 1
if x > pow(10, 9):
	x = -1
print(x)


from sys import stdin, stdout

def kth_largest_integer(k: int, sequence) -> int:
	sequence.sort()
	if k == 0:
		kth = sequence[0] - 1
	else:
		kth = sequence[k - 1]
	count = 0
	for num in sequence:
		if num <= kth:
			count += 1
	if count == k and kth > 0:
		return kth
	return -1

def kth_largest_integer_no_duplicates(k: int, sequence) -> int:
	start = 0
	end = len(sequence) - 1
	pivot = __random_partition_in_place(start, end, sequence)
	while start <= end:
		if k == pivot + 1:
			return sequence[pivot]
		elif k < pivot + 1:
			end = pivot - 1
			pivot = __random_partition_in_place(start, end, sequence)
		else:
			start = pivot + 1
			pivot = __random_partition_in_place(start, end, sequence)
	return -1

def __random_partition_in_place(start: int, end: int, sequence) -> int:
	pivot = randrange(start, end, 1)
	(sequence[start], sequence[pivot]) = (sequence[pivot], sequence[start])
	pivot = start
	start += 1
	while start <= end:
		if sequence[start] <= sequence[pivot]:
			(sequence[start], sequence[pivot]) = (sequence[pivot], sequence[start])
			pivot += 1
			start += 1
		else:
			(sequence[start], sequence[end]) = (sequence[end], sequence[start])
			end -= 1
	return pivot
(n, k) = map(int, stdin.readline().rstrip().split(' '))
sequence = [int(x) for x in stdin.readline().rstrip().split(' ')]
stdout.write(str(kth_largest_integer(k, sequence)) + '\n')


numbers = [int(n) for n in input().split()]
n = numbers[0]
k = numbers[1]
s = [int(n) for n in input().split()]
s = sorted(s)
if k == n:
	print(s[-1])
elif k > n:
	print('-1')
elif k == 0 and s[0] > 1:
	print(s[0] - 1)
elif k == 0 and s[0] == 1:
	print('-1')
elif s[k] == s[k - 1]:
	print('-1')
else:
	print(s[k - 1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.insert(0, 1)
a.append(pow(10, 10))
print(a[k] if not a[k] == a[k + 1] else -1)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
if n == k:
	print(arr[-1])
	exit()
if k == 0:
	ret = 1
	if arr[0] == 1:
		ret = -1
	print(ret)
	exit()
if arr[k - 1] == arr[k]:
	print(-1)
	exit()
print(arr[k - 1])


(n, k) = map(int, input().split())
arr = [int(i) for i in input().split()]
arr.sort()
if k == 0 and arr[0] == 1:
	print(-1)
elif k == 0:
	print(arr[0] - 1)
elif k == n:
	print(arr[-1])
elif arr[k - 1] == arr[k]:
	print(-1)
else:
	print(arr[k - 1])


k = int(input().split(' ')[1])
a = input().split(' ')
a = list(map(int, a))
a.sort()
if k == 0:
	if a[0] > 1:
		print(a[0] - 1)
	else:
		print('-1')
elif k != len(a) and a[k] == a[k - 1]:
	print('-1')
else:
	print(a[k - 1])


import sys
(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
if k == 0:
	print(1 if a[0] > 1 else -1)
elif k == n:
	print(a[k - 1])
elif a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k - 1])


(n, k) = list(map(int, input().split()))
s = list(map(int, input().split()))
s.sort()

def print_num():
	if k == 0:
		if s[0] == 1:
			return -1
		return 1
	elif n == k:
		return s[n - 1]
	elif s[k] > s[k - 1]:
		return s[k - 1]
	else:
		return -1
print(print_num())


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
if k == 0:
	if a[k] >= 2:
		print('1')
	else:
		print('-1')
else:
	try:
		if a[k - 1] == a[k]:
			print(-1)
		else:
			print(a[k - 1])
	except:
		print(a[k - 1])


import sys
input = sys.stdin.readline

def main():
	(n, k) = map(int, input().split())
	a = [1] + list(map(int, input().split()))
	a.sort()
	if k < n and a[k] == a[k + 1]:
		print(-1)
	else:
		print(a[k])
main()


s = input().split()
s = [int(i) for i in s]
a = input().split()
a = [int(i) for i in a]
a.sort()
if s[1] == 0 and a[0] - 1 != 0:
	print(a[0] - 1)
elif s[1] == 0 and a[0] - 1 == 0:
	print(-1)
elif s[1] == len(a) or a[s[1] - 1] != a[s[1]]:
	print(a[s[1] - 1])
elif a[s[1] - 1] == a[s[1]]:
	print(-1)


import sys
(n, k) = map(int, input().split())
lista = [int(i) for i in input().split()]
lista = sorted(lista)
if k == 0:
	print(1 if lista[0] > 1 else -1)
else:
	print(lista[k - 1] if k == n or lista[k] > lista[k - 1] else -1)


(n, k) = [int(s) for s in input().split(' ')]
a = [int(s) for s in input().split(' ')]
a.sort()
if k == 0:
	if a[0] > 1:
		print(1)
		exit()
	else:
		print(-1)
		exit()
if n == k:
	print(a[k - 1])
	exit()
if a[k] == a[k - 1]:
	print(-1)
else:
	print(a[k - 1])


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
s.append(1000000010)
s.sort()
b = s[k - 1]
c = s[k - 1]
d = s[k - 1] + 1
if k == 0:
	if s[0] == 1:
		print(-1)
	else:
		print(1)
elif s[k] == c:
	print(-1)
else:
	print(c)


(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
arr.sort()
if k == 0:
	if arr[0] > 1:
		print(1)
	else:
		print(-1)
elif k == n:
	print(arr[k - 1])
elif arr[k] == arr[k - 1]:
	print(-1)
else:
	print(arr[k - 1])


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()

def solve():
	if k == 0:
		return 1 if arr[0] > 1 else -1
	if n == k:
		return arr[k - 1]
	return -1 if arr[k - 1] == arr[k] else arr[k - 1]
print(solve())


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = a[0:k]
if k == 0 and a[0] != 1:
	print(a[k] - 1)
elif k == 0 and a[0] == 1:
	print(-1)
elif n == k:
	print(max(a))
elif a[k] == a[k - 1] and k != n:
	print(-1)
else:
	print(a[k] - 1)


(n, k) = map(int, input().split())
seq = [int(i) for i in input().split()]
seq.sort()
if k != 0:
	if n != k:
		pos = seq[k - 1]
		if seq[k] == seq[k - 1]:
			print(-1)
		else:
			print(seq[k - 1])
	else:
		print(seq[n - 1])
else:
	print(seq[0] - 1 if seq[0] - 1 >= 1 else -1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
if k == 0:
	if min(a) > 1:
		print(1)
	else:
		print(-1)
elif len(a) == 1:
	if k == 1:
		print(a[0])
	else:
		print(-1)
elif k > n:
	print(-1)
elif k == n:
	print(max(a))
elif a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k - 1])


(n, k) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
a.sort()
ans = -1
for i in range(n):
	if (i == n - 1 or a[i] < a[i + 1]) and k == i + 1:
		ans = a[i]
		break
mini = 1
if k == 0 and mini < a[0]:
	ans = mini
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
q = a[t - 1]
if t == n:
	print(a[-1])
elif t == 0:
	if a[0] > 1:
		print(a[0] - 1)
	else:
		print(-1)
elif a[t - 1] == a[t]:
	print(-1)
else:
	print(q)


(n_str, k_str) = input().split(' ')
n = int(n_str)
k = int(k_str)
array = sorted([int(c) for c in input().split(' ')])
if k == 0 and array[0] == 1:
	print(-1)
elif k == 0:
	print(1)
else:
	num = array[k - 1]
	if k < n and num == array[k]:
		print(-1)
	else:
		print(num)


(n, k) = map(int, input().split())
a = [*map(int, input().split())]
a.sort()
if k == 0:
	r = 1 if a[0] > 1 else -1
else:
	r = a[k - 1] if k == n or a[k] > a[k - 1] else -1
print(r)


(n, k) = map(int, input().split())
x = sorted(map(int, input().split()))
i = 0
if k == 0:
	if x[0] > 1:
		print(1)
	else:
		print(-1)
	exit()
while i < n:
	while i + 1 < n and x[i + 1] == x[i]:
		i += 1
	if i == k - 1:
		print(x[i])
		break
	if i > k - 1:
		print(-1)
		break
	i += 1


(n, k) = map(int, input().split())
temp = list(map(int, input().split()))
temp.sort()
st = 1
end = 10 ** 9 + 1
l = -1
for i in range(30):
	mid = (st + end) // 2
	st1 = 0
	end1 = n
	for i in range(18):
		mid1 = (st1 + end1) // 2
		if temp[mid1] > mid:
			end1 = mid1
		else:
			st1 = mid1
	met = st1 + 1
	if temp[0] > mid:
		met -= 1
	if met > k:
		end = mid
	elif met < k:
		st = mid
	else:
		l = 1
		break
if l == 1:
	print(mid)
else:
	print(-1)


def lessorequal(arr, n, k):
	arr.sort()
	if k == 0 and arr[0] != 1:
		print(arr[0] - 1)
		return
	elif k == 0:
		print(-1)
		return
	i = 0
	while i < n and arr[i] <= arr[k - 1]:
		i += 1
	if i - 1 == k:
		print(-1)
	else:
		print(arr[k - 1])
t = list(map(int, input().rstrip().split()))
n = t[0]
k = t[1]
arr = list(map(int, input().rstrip().split()))
lessorequal(arr, n, k)


(n, k) = list(map(int, input().split()))
num_list = sorted(list(map(int, input().split())))
if k == 0:
	x = num_list[0] - 1
	if x == 0:
		print(-1)
	else:
		print(x)
elif n == 1:
	print(num_list[0])
elif n == k:
	print(num_list[-1])
else:
	(x, xnext) = (num_list[k - 1], num_list[k])
	if xnext == x:
		print(-1)
	else:
		print(x)


(t, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
ans = 0
if k == 0:
	ans = l[0] - 1
else:
	ans = l[k - 1]
cnt = len([i for i in l if i <= ans])
if cnt != k or not (1 <= ans and ans <= pow(10, 9)):
	print(-1)
else:
	print(ans)


(n, k) = map(int, input().split(' '))
a = sorted(map(int, input().split(' ')))
if k == 0 and a[0] > 1:
	print(1)
elif k == n or a[k] > a[k - 1]:
	print(a[k - 1])
else:
	print(-1)


def klessequal(k, n, list_n):
	list_n.sort()
	if k == 0:
		if list_n[0] == 1:
			return -1
		return 1
	if n == 1 and k == 1:
		return list_n[0]
	if n == k:
		return list_n[-1]
	if list_n[k - 1] == list_n[k]:
		return -1
	return list_n[k - 1]
(n, k) = map(lambda x: int(x), input().split())
list_n = [int(x) for x in input().split()]
print(klessequal(k, n, list_n))


(length, n_elements) = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]
array.sort()
if n_elements == 0:
	if array[0] != 1:
		print('1')
	else:
		print('-1')
elif n_elements == length:
	print(array[length - 1])
elif array[n_elements - 1] != array[n_elements]:
	print(array[n_elements - 1])
else:
	print('-1')


from sys import stdin, stdout
sizes = [int(x) for x in stdin.readline().rstrip('\r\n').split()]
lst = [int(x) for x in stdin.readline().rstrip('\r\n').split()]

def solve(sizes, lst):
	(n, k) = (sizes[0], sizes[1])
	lst.sort()
	result = None
	if k == 0:
		result = lst[0] - 1
	elif k == n:
		result = lst[-1]
	elif lst[k - 1] < lst[k]:
		result = lst[k - 1]
	else:
		return str(-1)
	if result >= 1 and result <= 10 ** 9:
		return str(result)
	return str(-1)
stdout.write(solve(sizes, lst))


def main():
	(n, k) = liee()
	a = array()
	a.sort()
	if k == 0:
		print(1 if a[0] > 1 else -1)
	elif k == n:
		print(a[k - 1])
	elif a[k] > a[k - 1]:
		print(a[k - 1])
	else:
		print(-1)

def fun(m, n, s, k):
	return

def fun2(s):
	return
from sys import *
import inspect
import re
from math import *
import threading
from collections import *
from pprint import pprint as pp
mod = 998244353
MAX = 10 ** 5

def lie():
	return int(input())

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

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

def deb(p):
	for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
		m = re.search('\\bdeb\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)
		print('%s %d' % (m.group(1), p))

def vector(size, val=0):
	vec = [val for i in range(size)]
	return vec

def matrix(rowNum, colNum, val=0):
	mat = []
	for i in range(rowNum):
		collumn = [val for j in range(colNum)]
		mat.append(collumn)
	return mat

def dmain():
	setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
dmain()


def findEleLess(m, lst, n):
	cnt = 0
	for i in range(n):
		if lst[i] <= m:
			cnt += 1
	return cnt
(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
l = 1
h = 1000000000
ans = -1
while l <= h:
	m = (l + h) // 2
	x = findEleLess(m, lst, n)
	if x == k:
		ans = m
		break
	elif x > k:
		h = m - 1
	else:
		l = m + 1
print(ans)


(n, k) = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
d = {}
for i in range(n):
	if s[i] not in d:
		d[s[i]] = 1
	else:
		d[s[i]] += 1
q = []
for i in d:
	q.append((i, d[i]))
q.sort()
l = 0
if k == 0:
	if q[0][0] == 1:
		print(-1)
		exit()
	else:
		print(q[0][0] - 1)
		exit()
for i in range(len(d)):
	l += q[i][1]
	if l == k:
		print(q[i][0])
		exit()
print(-1)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
if k == 0:
	if lst[0] != 1:
		print(lst[0] - 1)
	else:
		print(-1)
	from sys import exit
	exit()
if k == n:
	print(lst[k - 1])
elif lst[k] - lst[k - 1] > 0:
	print(lst[k] - 1)
else:
	print(-1)


(n, k) = map(int, input().split())
array = list(map(int, input().split()))
array = sorted(array)
if k != n:
	if (array[k - 1] != array[k]) & (k != 0):
		print(array[k - 1])
	elif k == 0:
		if array[0] != 1:
			print(1)
		else:
			print(-1)
	else:
		print(-1)
else:
	print(array[-1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if k <= len(a):
	if k == 0:
		x = 1
	else:
		x = a[k - 1]
	if k <= len(a) - 1:
		if x == a[k]:
			print(-1)
		else:
			print(x)
	else:
		print(x)
else:
	print(-1)


from sys import stdin as si
from collections import Counter as C

class Solution:

	def bazinga(self, s, k, t):
		n = 1
		ck = False
		st = sorted(t.items())
		if k == 0:
			if st[0][0] == 1:
				return -1
			else:
				return st[0][0] - 1
		for i in range(len(st)):
			n = st[i][0]
			k -= st[i][1]
			if k == 0:
				break
			if k < 0:
				ck = True
				break
		if ck and k + t[n] != 0:
			return -1
		return n
(m, n) = map(int, si.readline().strip().split())
t = C(tuple(map(int, si.readline().strip().split())))
S = Solution()
print(S.bazinga(m, n, t))


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = sorted(arr)
temp = arr[k - 1] if k > 0 else 1
if k == 0:
	print(-1 if arr[0] == 1 else 1)
elif k < len(arr) and temp == arr[k]:
	print(-1)
else:
	print(temp)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(n, k) = zz()
l = [1] + szzz()
p = l[k]
if k >= n:
	p = l[k]
	print(p)
	exit()
print(p if l[k + 1] - l[k] else -1)


import sys
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(1)
elif k == n or a[k - 1] != a[k]:
	print(a[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
s = set(arr)
if k == n:
	print(arr[n - 1])
elif k == 0:
	q = arr[0] - 1
	if 1 <= q <= 1000000000:
		print(q)
	else:
		print(-1)
elif arr[k - 1] == arr[k]:
	print(-1)
else:
	print(arr[k - 1])


from collections import defaultdict
d = defaultdict(int)
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = [1] + arr
arr.sort()
if k == n or arr[k + 1] - arr[k]:
	print(arr[k])
else:
	print(-1)


(n, k) = map(int, input().split())
arr = list(map(int, input().strip().split()))
arr.sort()
if k == 0:
	if 1 in arr:
		print(-1)
	else:
		print(1)
elif k < n and arr[k] != arr[k - 1] or k == n:
	print(arr[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if k == 0:
	print(1 if l[0] > 1 else -1)
else:
	print(l[k - 1] if k == n or l[k] != l[k - 1] else -1)


from functools import reduce
from collections import Counter
(n, k) = [int(x) for x in input().split()]
ans = reduce(lambda x, y: x if x[1] >= k else (y[0], x[1] + y[1]), sorted(Counter((int(x) for x in input().split())).items()))
if k == 0:
	print(1 if ans[0] > 1 else -1)
else:
	print(ans[0] if ans[1] == k else -1)


def res(l, N, k):
	if k == 0 and l[0] > 1:
		return 1
	if k == 0 and l[0] == 1:
		return -1
	if k > N:
		return -1
	if k == N:
		return l[N - 1]
	if l[k - 1] == l[k]:
		return -1
	else:
		return l[k - 1]
(N, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(res(l, N, k))


import sys
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if k == 0:
	print(-1 if a[0] == 1 else 1)
	sys.exit()
(l, r, cnt) = [0] * 3
while l < n:
	while r < n and a[l] == a[r]:
		r += 1
	cnt += r - l
	if cnt == k:
		print(a[l])
		sys.exit()
	l = r
print(-1)


(n, k) = [int(x) for x in input().split()]
numbers = [int(x) for x in input().split()]
numbers.sort()
answer = 0
if k == 0:
	if 1 <= numbers[k] - 1 and numbers[k] - 1 <= 10 ** 9:
		answer = numbers[k] - 1
	else:
		answer = -1
if k == n:
	if 1 <= numbers[n - 1] and numbers[n - 1] <= 10 ** 9:
		answer = numbers[n - 1]
	else:
		answer = -1
if k > n:
	answer = -1
if 1 <= k and k < n:
	k = k - 1
	if 1 <= numbers[k] and numbers[k] <= 10 ** 9 and (numbers[k + 1] > numbers[k]):
		answer = numbers[k]
	else:
		answer = -1
print(answer)


(n, k) = map(int, input().split())
ara = list(map(int, input().strip().split()))
ara.sort()
ans = ara[k - 1]
cnt = 0
if k == 0 and ara[0] != 1:
	print(1)
elif k == 0 and ara[0] == 1:
	print(-1)
elif k == n:
	print(ara[n - 1])
elif ara[k - 1] == ara[k]:
	print(-1)
else:
	print(ara[k - 1])


(n, k) = [int(x) for x in input().split(' ')]
seq = [int(x) for x in input().split(' ')]
seq = sorted(seq)
if k == 0:
	ans = seq[0] - 1
else:
	ans = seq[k - 1]
cnt = 0
while True:
	if cnt < n and seq[cnt] <= ans:
		cnt += 1
	else:
		break
if cnt != k or ans < 1:
	print('-1')
else:
	print(ans)


l1 = input()
(n_s, k_s) = l1.split()
(n, k) = (int(n_s), int(k_s))
sequ_s = input()
s = [int(elem) for elem in sequ_s.split()]
s = sorted(s)
if k == 0:
	if s[0] <= 1:
		print(-1)
	else:
		print(1)
elif k > len(s):
	print(-1)
elif k == len(s):
	print(10 ** 9)
else:
	chosen_elem = s[k - 1]
	if k < len(s) and s[k] == chosen_elem:
		print(-1)
	else:
		print(chosen_elem)


(size, k) = map(int, input().split())
limitH = 1000000000
dec = sorted(map(int, input().split()))
if size == 1:
	if k == 0:
		print(1 if dec[0] != 1 else -1)
	else:
		print(dec[0])
elif size == k:
	rul = dec[-1]
	print(rul if rul <= limitH else -1)
else:
	point = dec[k - 1] if dec[k] != dec[k - 1] else 0
	if k == 0:
		print(1 if dec[0] != 1 else -1)
	else:
		print(point if point <= limitH and point > 0 else -1)


x = input().split()
(n, k) = (int(x[0]), int(x[1]))
x = input().split()
nums = []
for num in x:
	nums.append(int(num))
nums.sort()
if k == 0:
	ans = nums[0] - 1
else:
	ans = nums[k - 1]
cnt = 0
for item in nums:
	if item <= ans:
		cnt += 1
if cnt != k or ans < 1:
	print(-1)
else:
	print(ans)


il = int(input().split()[1]) - 1
ll = input().split()
for i in range(len(ll)):
	ll[i] = int(ll[i])
ll.sort()
opt = ll[il]
if il == -1:
	if 1 in ll:
		print(-1)
	else:
		print(1)
elif il < len(ll) - 1:
	if ll[il] == ll[il + 1]:
		print(-1)
	else:
		print(opt)
else:
	print(opt)


nk = input().split(' ')
k = int(nk[1])
data = input().split(' ')
data = [int(x) for x in data]
data.sort()
if k == 0:
	m = data[0]
if k != 0:
	m = data[k - 1]
if k == 0 and m == 1:
	print(-1)
elif k == 0 and m != 1:
	print(1)
elif k != len(data):
	if m != data[k]:
		print(m)
	else:
		print(-1)
else:
	print(m)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if k == 0:
	g = l[0] - 1
	if g <= 0:
		print(-1)
	else:
		print(g)
elif len(l) == 1:
	if l[0] > 0:
		print(l[0])
	else:
		print(-1)
else:
	try:
		if l[k - 1] == l[k]:
			print(-1)
		else:
			print(l[k - 1])
	except:
		print(l[k - 1])


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
if n == k:
	print(max(a))
elif k == 0:
	if min(a) == 1:
		print(-1)
	else:
		print(1)
else:
	a.sort()
	if a[k - 1] == a[k]:
		print(-1)
	else:
		print(a[k - 1])


(n, k) = map(int, input().split())
u = list(map(int, input().split()))
u.sort()
u.append(u[-1] + 1)
if k == 0:
	if u[0] > 1:
		print(u[0] - 1)
	else:
		print(-1)
elif u[k - 1] != u[k]:
	print(u[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if n == k:
	print(l[-1])
	exit(0)
if k == 0:
	if l[0] > 1:
		print(1)
	else:
		print(-1)
else:
	z = l[:k]
	if l[k] == z[-1]:
		print(-1)
	else:
		print(z[-1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
sor = sorted(a)
if k == 0:
	if sor[0] == 1:
		print(-1)
	else:
		print(sor[0] - 1)
elif k < n and sor[k - 1] == sor[k]:
	print(-1)
else:
	print(sor[k - 1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(1)
	exit()
if k == n or a[k] != a[k - 1]:
	print(a[k - 1])
else:
	print(-1)


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
dgl = lambda : list(map(int, input()))
il = lambda : list(map(int, input().split()))
(n, k) = f()
l = sorted(il())
if k == n:
	print(l[n - 1])
elif k == 0:
	print(l[0] - 1 if l[0] > 1 else -1)
elif l[k - 1] == l[k]:
	print(-1)
else:
	print(l[k - 1])


(n, k) = [int(i) for i in input().strip().split()]
N = sorted([int(i) for i in input().strip().split()])
m = 0
if k == 0:
	print(1 if min(N) > 1 else -1)
else:
	counter = k
	for i in range(k, n):
		if N[i] <= N[k - 1]:
			counter += 1
			break
	if counter == k:
		m = 1
		print(N[k - 1])
	if m != 1:
		print(-1)


(n, k) = map(int, input().split())
arr = sorted(map(int, input().split()))
ans = None
if k == 0:
	if arr[0] == 1:
		ans = -1
	else:
		ans = 1
elif k < n and arr[k - 1] == arr[k]:
	ans = -1
else:
	ans = arr[k - 1]
print(ans)


(n, k) = map(int, input().split(' '))
X = [int(x) for x in input().split(' ')]
X.sort()
if k == 0:
	if X[0] == 1:
		print(-1)
	else:
		print(1)
elif n == k:
	print(X[k - 1])
elif n != k:
	if X[k] == X[k - 1]:
		print(-1)
	elif X[k] > X[k - 1]:
		print(X[k - 1])
elif k == 1:
	print(X[k - 1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(a[0] - 1)
	exit(0)
cnt = sum([1 for el in a if el <= a[k - 1]])
if cnt == k:
	print(a[k - 1])
else:
	print(-1)


(n, k) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
arr.sort()
ans = arr[k - 1] if k > 0 else arr[0] - 1
cnt = 0
for i in arr:
	if i <= ans:
		cnt += 1
print(ans if ans >= 1 and cnt == k else -1)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
pairs = []
for (key, value) in d.items():
	pairs.append([key, value])
pairs = sorted(pairs, key=lambda item: item[0])
if k == 0:
	if pairs[0][0] > 1:
		print(pairs[0][0] - 1)
		exit()
	else:
		print(-1)
		exit()
c = 0
for i in range(len(pairs)):
	c += pairs[i][1]
	if c == k:
		print(pairs[i][0])
		exit()
	else:
		continue
print(-1)


def less_or_equal(n, k, a):
	if k == 0:
		if a[0] > 1:
			return 1
		else:
			return -1
	elif k == n or a[k] > a[k - 1]:
		return a[k - 1]
	else:
		return -1
(n, k) = list(map(int, input().split()))
aa = sorted(list(map(int, input().split())))
print(less_or_equal(n, k, aa))


n = list(map(int, input().split()))
k = n[1]
n = n[0]
l = list(map(int, input().split()))
l.sort()
if k > len(l) - 1:
	if l[len(l) - 1] > 10 ** 9:
		print(-1)
	else:
		print(l[len(l) - 1])
elif k == 0:
	if l[0] - 1 < 1:
		print(-1)
	else:
		print(l[0] - 1)
elif l[k - 1] < l[k]:
	if l[k - 1] > 10 ** 9:
		print(-1)
	else:
		print(l[k - 1])
elif l[k - 1] == l[k]:
	print(-1)


(n, k) = [int(x) for x in input().split()]
li = [int(x) for x in input().split()]
li1 = sorted(li)
if k == 0:
	if li1[0] == 1:
		print(-1)
		quit()
	else:
		print(1)
		quit()
if n == 1:
	print(li1[0])
	quit()
if n == k:
	print(li1[k - 1])
	quit()
if li1[k - 1] == li1[k] and k < n:
	print(-1)
	quit()
else:
	print(li1[k - 1])


def f(n, k, A):
	if k == 0:
		if 1 in A:
			return -1
		return 1
	if k == len(A):
		return max(A)
	A.sort()
	if A[k] == A[k - 1]:
		return -1
	else:
		return A[k - 1]
(a, b) = map(int, input().split())
A = list(map(int, input().split()))
print(f(a, b, A))


def main():
	(n, k) = [int(_) for _ in input().split()]
	a = [int(_) for _ in input().split()] + [1, 10 ** 9 + 1]
	a.sort()
	if a[k] < a[k + 1]:
		print(a[k])
	else:
		print(-1)
main()


(n, k) = map(int, input().split())
mass = list(map(int, input().split()))
mass.sort()
mass.insert(k, mass[k - 1])
if k == 0:
	if min(mass) > 1:
		print(1)
	else:
		print(-1)
elif k == n:
	print(mass[k])
elif mass[k] >= mass[k + 1]:
	print(-1)
else:
	print(mass[k])


(n, k) = map(int, input().split())
seq = [int(x) for x in input().split()]
seq.sort()
if k == 0:
	if seq[0] == 1:
		print('-1')
	else:
		print(seq[0] - 1)
elif k < n and seq[k - 1] != seq[k]:
	print(seq[k - 1])
elif k == n:
	print(seq[k - 1])
else:
	print('-1')


t = [int(j) for j in input().split()]
n = t[0]
k = t[1]
arr = [int(j) for j in input().split()]
arr.sort()
x = -1
if k == n:
	if arr[n - 1] <= 10 ** 9:
		x = arr[n - 1]
elif k == 0 and arr[0] != 1:
	x = arr[0] - 1
elif arr[k] - arr[k - 1] >= 1:
	x = arr[k - 1]
print(x)


def main():
	(n, k) = input().split(' ')
	k = int(k)
	sequence = map(int, input().split(' '))
	counts = dict()
	for value in sequence:
		counts[value] = counts.get(value, 0) + 1
	sorted_sequence = sorted(counts.items())
	if k == 0:
		if sorted_sequence[0][0] > 1:
			return 1
		else:
			return -1
	for i in range(0, len(sorted_sequence)):
		if sorted_sequence[i][1] < k:
			k -= sorted_sequence[i][1]
			continue
		elif sorted_sequence[i][1] == k:
			return sorted_sequence[i][0]
		else:
			return -1
output = main()
print(output)


(n, k) = input().split()
n = int(n)
k = int(k)
mas = input().split()
mas = sorted(mas, key=lambda x: int(x))
if n == 0:
	if k == 0:
		print(1)
	else:
		print(-1)
elif k == 0:
	if int(mas[0]) > 1:
		print(int(mas[0]) - 1)
	else:
		print(-1)
elif k < len(mas) and int(mas[k - 1]) == int(mas[k]):
	print(-1)
else:
	print(mas[k - 1])


R = lambda : map(int, input().split())
(n, k) = R()
a = list(R())
a.sort()
a.append(10 ** 9 + 10)
ans = None
if k == 0:
	ans = a[0] - 1
elif a[k - 1] == a[k]:
	ans = -1
else:
	ans = a[k - 1]
if ans < 1:
	ans = -1
print(ans)


(n, k) = [int(s) for s in input().split()]
a = sorted((int(s) for s in input().split()))
if k == 0:
	print(a[0] - 1 if a[0] > 1 else -1)
elif k == n:
	print(a[-1])
else:
	print(a[k - 1] if a[k - 1] < a[k] else -1)


import sys
(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
z = 0
x = -1
a.sort()
i = 0
if k == 0:
	if a[0] == 1:
		print(-1)
		sys.exit()
	else:
		print(1)
		sys.exit()
if n == k:
	print(a[-1])
	sys.exit()
while k > i:
	if a[i] == a[i + 1]:
		i += 2
		if i > k:
			print(-1)
			sys.exit()
	else:
		i += 1
if i < n:
	if a[i] == a[i - 1]:
		print(-1)
		sys.exit()
print(a[i - 1])


import sys
(n, k) = map(int, next(sys.stdin).rstrip().split())
xs = list(map(int, next(sys.stdin).rstrip().split()))
xs.sort()
assert len(xs) == n
if k == 0:
	print(-1 if xs[0] == 1 else 1)
elif k > len(xs):
	print(-1)
elif k == len(xs):
	print(xs[-1])
elif xs[k - 1] == xs[k]:
	print(-1)
else:
	print(xs[k - 1])


(n, k) = map(int, input().strip().split(' '))
a = sorted(map(int, input().strip().split(' ')))
if k is 0:
	print(-1 if a[0] < 2 else a[0] - 1)
elif k is n:
	print(a[-1])
else:
	print(-1 if a[k - 1] == a[k] else a[k - 1])


(n, k) = input().split()
n = int(n)
k = int(k)
a = [int(i) for i in input().split()]
a.sort()
num = a[k - 1]
ans = 0
for i in a:
	if i <= num:
		ans += 1
if k == 0:
	num = a[0] - 1
	ans = 0
	if num <= 0:
		print(-1)
		exit()
if ans != k:
	print(-1)
else:
	print(num)


(n, k) = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
A.insert(0, 1)
A.insert(n + 1, A[n] + 1)
if A[k] != A[k + 1]:
	print(A[k])
else:
	print(-1)


(n, k) = input().split(' ')
(n, k) = (int(n), int(k))
seq = input().split(' ')
for i in range(len(seq)):
	seq[i] = int(seq[i])
orde = sorted(seq)
if k == 0:
	if 1 < orde[0]:
		print(1)
	else:
		print(-1)
elif k == n:
	print(orde[-1])
elif orde[k] > orde[k - 1]:
	print(orde[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
f = k
lst = list(map(int, input().split(' ')))
lst = sorted(lst)
mp = {}
for i in lst:
	if i in mp:
		mp[i] += 1
	else:
		mp[i] = 1
tmp = -1
c = 0
for i in mp:
	k -= mp[i]
	if k == 0:
		tmp = i
if f == 0 and n >= 1 and (lst[0] > 1):
	print(1)
else:
	print(tmp)


from bisect import *
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if k == 0:
	if l[0] != 1:
		print(1)
	else:
		print(-1)
	exit()
if k == n:
	print(l[-1])
	exit()
elif l[k - 1] < l[k]:
	print(l[k - 1])
else:
	print(-1)


from sys import stdin, stdout
inp = stdin.readline
op = stdout.write
(n, k) = list(map(int, inp().split()))
a = list(map(int, inp().split()))
a.sort()
if k == 0:
	if a[0] - 1 > 0 and a[0] - 1 <= 1000000000.0:
		op(str(a[0] - 1))
	else:
		op(str(-1))
elif k >= n:
	op(str(a[n - 1]))
elif a[k - 1] == a[k]:
	op(str(-1))
elif a[k - 1] > 0 and a[k - 1] <= 1000000000.0:
	op(str(a[k - 1]))
else:
	op(str(-1))


[n, k] = map(int, input().strip().split())
ais = list(map(int, input().strip().split()))
ais.sort()
if k == 0:
	if ais[0] == 1:
		print(-1)
	else:
		print(ais[0] - 1)
elif k == n or ais[k] > ais[k - 1]:
	print(ais[k - 1])
else:
	print(-1)


(m, n) = map(int, input().split())
c = 0
a = list(map(int, input().split()))
a = sorted(a)
if n == 0:
	ans = a[0] - 1
else:
	ans = a[n - 1]
for i in range(len(a)):
	if a[i] <= ans:
		c += 1
	else:
		break
if c == n:
	if ans < 1:
		print(-1)
	else:
		print(ans)
else:
	print(-1)


(n, k) = map(int, input().split())
ls = [int(x) for x in input().split()]
ls.sort()
if k == 0:
	if ls[0] > 1:
		print(1)
	else:
		print('-1')
else:
	ls1 = ls[k:]
	if ls1.count(ls[k - 1]) == 0:
		print(ls[k - 1])
	else:
		print(-1)


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a)
	if k == 0:
		if a[0] == 1:
			print(-1)
		else:
			print(a[0] - 1)
		return
	x = a[k - 1]
	if k == n or a[k] != x:
		print(x)
	else:
		print(-1)
main()


from collections import defaultdict
from string import ascii_lowercase
from sys import stdin, stdout
input = stdin.readline

def main():
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	if k == 0:
		res = a[0] - 1
		if res < 1:
			print(-1)
		else:
			print(res)
	elif k < n and a[k] == a[k - 1]:
		print(-1)
	else:
		print(a[k - 1])
main()


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l1 = l[:]
l1.sort()
if k == 0:
	if min(l1) == 1:
		print(-1)
	else:
		print(1)
elif k == n:
	print(max(l1))
else:
	ek = l1[k - 1]
	ek1 = l1[k]
	if ek1 == ek:
		print(-1)
	else:
		print(ek)


a = list(map(int, input().split()))
n = a[0]
k = a[1]
c = list(map(int, input().split()))
c.sort()
if k == 0:
	if c[0] == 1:
		print('-1')
	else:
		print(c[0] - 1)
elif k == n:
	print(c[k - 1])
else:
	flag = 0
	m = c[k - 1]
	j = c[k]
	for i in range(m, j):
		if i not in c:
			flag += 1
			print(i)
			break
	if flag == 0 and m != j:
		print(m)
		flag += 1
	if flag == 0:
		print('-1')


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
cnt = 1
m = 0
if k == 0:
	if a[0] > 1:
		print(1)
	else:
		print(-1)
elif n == 1:
	if k == 1:
		print(a[0])
	else:
		print(-1)
else:
	f = 2
	for i in range(n - 1):
		if a[i] == a[i + 1]:
			cnt += 1
		else:
			m += cnt
			if m > k:
				f = 0
				break
			elif m == k:
				f = 1
				break
			else:
				cnt = 1
	if f == 1:
		print(a[i])
	elif f == 0:
		print(-1)
	else:
		m += cnt
		if m == k:
			print(a[i + 1])
		else:
			print(-1)


(n, k) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
if k == 0:
	if l[0] > 1:
		print(l[0] - 1)
	else:
		print(-1)
else:
	p = l[k - 1]
	if k < n:
		if l[k] != p:
			print(l[k - 1])
		else:
			print(-1)
	else:
		print(l[k - 1])


(n, k) = map(int, input().split())
A = sorted(map(int, input().split()))
if k == 0:
	if A[0] == 1:
		print(-1)
	else:
		print(A[0] - 1)
elif k == n:
	print(int(1000000000.0))
else:
	x = A[k - 1]
	if A[k] == x:
		print(-1)
	else:
		print(x)


from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
array = list(map(int, stdin.readline().split()))
array.sort()
at = 0
if k == 0 and array[0] == 1:
	print(-1)
elif k == 0 and array[0] != 1:
	print(1)
elif n == k:
	print(max(array))
elif array[k - 1] != array[k]:
	print(array[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split(' '))
l = [int(x) for x in input().split(' ')]
l = sorted(l)
c = l[:]
if len(l) < k:
	print(-1)
else:
	t = l[k] if len(l) > k else -1
	l = l[:k]
	res = l[-1] if k != 0 else -1 if c[0] == 1 else c[0] - 1
	if res == t:
		print(-1)
	else:
		print(res)


import sys
import array
(n, k) = [int(x) for x in input().split()]
a = array.array('i', [int(x) for x in input().split()])
a = sorted(a)
if k == 0:
	if a[0] == 1:
		print(-1)
		sys.exit()
	else:
		print(a[0] - 1)
		sys.exit()
k -= 1
if k == n - 1:
	print(a[k])
	sys.exit()
elif a[k] == a[k + 1]:
	print(-1)
	sys.exit()
else:
	print(a[k])
	sys.exit()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(a)
if k == 0:
	if b[0] == 1:
		print('-1')
	else:
		print('1')
elif k == n or b[k - 1] != b[k]:
	print(b[k - 1])
else:
	print('-1')


x = input()
(n, k) = map(int, x.split())
line = input()
arr = list(map(int, line.split()))
arr.sort()
if k == 0:
	if arr[0] == 1:
		print(-1)
	else:
		print(1)
elif k != n:
	if arr[k] == arr[k - 1]:
		print(-1)
	else:
		print(arr[k - 1])
else:
	print(arr[k - 1])


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

def input_int():
	return int(input())
(N, K) = input_list_int()
array = input_list_int()
array.sort()
if K == 0:
	if min(array) >= 2:
		print(1)
	else:
		print(-1)
else:
	f = array[K - 1]
	if len(array) > K and array[K] == f:
		print(-1)
	else:
		print(f)


def kum(n, k, a):
	a.sort()
	if k == 0 and a[0] > 1:
		return a[0] - 1
	if k == 0 and a[0] == 1:
		return -1
	if n == 0:
		return -1
	if n < k:
		return -1
	if n == k:
		return a[n - 1]
	for i in range(k - 1, n):
		if a[i] < a[i + 1]:
			return a[i]
		if a[i] == a[i + 1]:
			return -1
nk = input().split()
n = int(nk[0])
k = int(nk[1])
a = list(map(int, input().rstrip().split()))
ans = kum(n, k, a)
print(ans)


l = input().split()
n = int(l[0])
k = int(l[1])
l = input().split()
li = [int(i) for i in l]
li.sort()
if k == 0:
	if li[0] == 1:
		print(-1)
	else:
		print(1)
	quit()
z = li[k - 1]
if k < n and z == li[k]:
	print(-1)
	quit()
print(li[k - 1])


import sys
import os
import math
t = sys.stdin.readline()
vals = t.split()
n = int(vals[0])
k = int(vals[1])
t = sys.stdin.readline()
vals = t.split()
numbers = []
for val in vals:
	numbers.append(int(val))
numbers.sort()
if k == 0:
	if numbers[0] - 1 > 0:
		print(numbers[0] - 1)
	else:
		print(-1)
elif k == n:
	if numbers[-1] + 1 > 1000000000.0:
		print(numbers[-1])
	else:
		print(numbers[-1])
elif numbers[k - 1] < numbers[k]:
	print(numbers[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split(' '))
l = list(map(int, input().split()))
l.sort()
if k != 0 and k != n:
	if l[k] == l[k - 1]:
		print(-1)
	elif l[k - 1] > 0 and l[k - 1] <= 10 ** 9:
		print(l[k - 1])
	else:
		print(-1)
elif k == 0:
	x = min(l) - 1
	if x > 0 and x <= 10 ** 9:
		print(x)
	else:
		print(-1)
else:
	x = max(l)
	if x <= 10 ** 9 and x > 0:
		print(x)
	else:
		print(-1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if k == 0 and a[0] == 1:
	print(-1)
elif k == 0:
	print(a[0] - 1)
else:
	c = 0
	for i in range(n):
		if a[k - 1] >= a[i]:
			c += 1
	print(a[k - 1] if c == k else -1)


class Solution:

	def solve(self, n, k, seq):
		seq.sort()
		if k == 0:
			x = seq[0] - 1
		else:
			x = seq[k - 1]
		count = 0
		for i in range(0, n):
			if seq[i] <= x:
				count += 1
		if x < 1 or count != k:
			return -1
		return x
sol = Solution()
in1 = input().split()
n = int(in1[0])
k = int(in1[1])
s = input().split()
s = list(map(int, s))
print(sol.solve(n, k, s))


st = input().split()
n = int(st[0])
k = int(st[1])
liste = input().split()
for i in range(n):
	liste[i] = int(liste[i])
liste.sort()
if k == 0:
	if liste[0] != 1:
		print(1)
	else:
		print(-1)
elif k == n:
	print(liste[k - 1])
elif liste[k] == liste[k - 1]:
	print(-1)
else:
	print(liste[k - 1])


import math
import string
a = []
s = str(input()).split()
n = int(s[0])
k = int(s[1])
b = str(input()).split()
for i in range(0, n):
	a.append(int(b[i]))
a.sort()
if k == 0:
	if a[0] == 1:
		print('-1')
	else:
		print('1')
else:
	ans = a[k - 1]
	cnt = 0
	for i in range(0, n):
		if a[i] <= ans:
			cnt += 1
	if cnt != k:
		ans = -1
	print(ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
(n, k) = l()
A = l()
A.sort()
if k == 0:
	if A[0] <= 1:
		print(-1)
		exit()
	else:
		print(A[0] - 1)
		exit()
if k == n:
	print(A[-1])
	exit()
x = A[k - 1]
if A[k] != A[k - 1]:
	print(A[k - 1])
	exit()
else:
	print(-1)
	exit()


(n, k) = list(map(int, input().split()))
a = sorted(map(int, input().split()))
res = -1
if k == 0 and a[0] > 1:
	res = a[0] - 1
elif k == n:
	res = a[-1]
elif a[k] - a[k - 1] > 0:
	res = a[k - 1]
print(res)


(x, y) = map(int, input().split())
g = [1] + [int(_) for _ in input().split()]
t = sorted(g)
if x == y or t[y + 1] != t[y]:
	print(t[y])
else:
	print('-1')


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if k == n:
	print(a[k - 1])
elif k == 0 and a[0] > 1:
	print(1)
elif k == 0 and a[0] == 1:
	print(-1)
elif len(a) > 1 and a[k - 1] == a[k]:
	print(-1)
else:
	if len(a) == 1 and k == 1:
		print(a[0])
		exit(0)
	elif len(a) == 1 and k > 1:
		print(-1)
		exit(0)
	print(a[k - 1])


from collections import defaultdict, Counter

def solve(a, k):
	a.sort()
	if k == 0:
		ans = a[0] - 1
	else:
		ans = a[k - 1]
	cnt = 0
	for i in a:
		if i <= ans:
			cnt += 1
	if cnt != k:
		print(-1)
		return
	if ans <= 0 or ans > 10 ** 9:
		print(-1)
		return
	print(ans)
	return
n = list(map(int, input('').split(' ')))
a = list(map(int, input('').split(' ')))
solve(a, n[1])


from collections import Counter

def read_numbers():
	return (int(s) for s in input().strip().split(' '))

def main():
	(n, k) = read_numbers()
	arr = list(read_numbers())
	count = Counter(arr)
	count = sorted(count.items(), key=lambda k: k)
	res = 0
	if k == 0:
		if 1 in arr:
			return -1
		else:
			return 1
	for (num, c) in count:
		res += c
		if res == k:
			return num
		if res > k:
			return -1
	return -1
print(main())


(n, k) = map(int, input().split())
list_ = list(map(int, input().split()))
list_.append(1)
list_.append(1000000001)
j = sorted(list_)
access = j[k]
if j[k] != j[k + 1]:
	print(j[k])
else:
	print('-1')


def buz(n, k, ll):
	count = 0
	for i in range(len(ll)):
		if ll[i] <= n:
			count += 1
	if count == k:
		return 0
	if count > k:
		return 1
	return -1
(n, k) = map(int, input().split())
ll = map(int, input().split())
ll = sorted(ll)
lo = 1
hi = 10 ** 9
ans = hi + 1
mid = int()
while lo <= hi:
	mid = lo + (hi - lo) // 2
	temp = buz(mid, k, ll=ll)
	if temp == 0:
		ans = mid
		break
	elif temp == 1:
		hi = mid - 1
	elif temp == -1:
		lo = mid + 1
if ans == 1000000001:
	ans = -1
print(ans)


X = input().split(' ')
Y = sorted(list(map(int, input().split(' '))))
if int(X[1]) == len(Y):
	print(Y[-1])
elif int(X[1]) == 0:
	if Y[0] == 1:
		print(-1)
	else:
		print(Y[0] - 1)
elif Y[int(X[1]) - 1] != Y[int(X[1])]:
	print(Y[int(X[1]) - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
num = list(map(int, input().split()))
num.sort()
if k == 0:
	if num[0] >= 2:
		print(num[0] - 1)
	else:
		print(-1)
elif k == n or num[k - 1] < num[k]:
	print(num[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
alist = list(map(int, input().split()))
alist.sort()
if k == 0:
	if alist[0] > 1:
		print(1)
	else:
		print(-1)
else:
	ans = alist[k - 1]
	if k < n:
		nextt = alist[k]
		if nextt == ans:
			print(-1)
		elif ans <= 1000000000:
			print(ans)
		else:
			print(-1)
	elif alist[-1] <= 1000000000:
		print(alist[-1])
	else:
		print(-1)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
if n >= 2:
	if k == 0:
		if a[0] == 1:
			print(-1)
		else:
			print(a[0] - 1)
	elif n == k:
		print(max(a))
	elif a[k] == a[k - 1]:
		print(-1)
	else:
		print(a[k - 1])
else:
	if n == 1 and k == 1:
		print(a[0])
	if n == 1 and k == 0:
		if a[0] == 1:
			print(-1)
		else:
			print(a[0] - 1)


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

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

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

def c(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def main():
	(n, k) = vars()
	arr = array()
	arr.sort()
	m = {}
	for i in range(n):
		m[arr[i]] = i
	if k == 0 and arr[0] > 1:
		print(1)
	elif m[arr[k - 1]] + 1 > k:
		print(-1)
	else:
		print(arr[k - 1])
t = 1
for _ in range(t):
	main()


from functools import reduce
import math
from decimal import *

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def sol():
	(am, num) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort()
	if num == 0:
		if arr[0] == 1:
			print('-1')
		else:
			print('1')
		return 0
	if num == am:
		print(arr[num - 1])
	elif arr[num - 1] == arr[num]:
		print(-1)
	else:
		print(arr[num - 1])
sol()


import sys
from collections import defaultdict
from math import sqrt
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def s(d):
	dis = 1 + 4 * 2 * 3 * d
	ds = sqrt(dis)
	return (-1 + ds) / 6

def add(r, v, m):
	if len(r) < m:
		r.append(v)
		r.sort(reverse=True)
	elif r[-1] < v:
		r.append(v)
		r.sort(reverse=True)
	return r[0:m]

def main():
	(n, m) = inlt()
	vals = inlt()
	vals.sort()
	v = vals[m - 1]
	if m == 0:
		print(vals[0] - 1 if vals[0] - 1 >= 1 else -1)
	elif m <= n - 1:
		if v == vals[m]:
			print(-1)
		else:
			print(v)
	else:
		print(v)
main()


(x, y) = [int(c) for c in input().split()]
w = [int(d) for d in input().split()]
w.sort()
ans = 0
if y == 0:
	ans = w[0] - 1
else:
	ans = w[y - 1]
cnt = 0
for i in w:
	if i <= ans:
		cnt += 1
if cnt != y or not (1 <= ans and ans <= 1000 ** 3):
	ans = -1
print(ans)


import sys
n = sys.stdin.readline()
while n:
	x = int(n.split()[0])
	y = int(n.split()[1])
	li = sorted([int(val) for val in sys.stdin.readline().split()])
	if y == 0:
		if li[0] == 1:
			print('-1')
		else:
			print(li[0] - 1)
	elif y == x:
		print(li[y - 1])
	elif li[y] == li[y - 1]:
		print('-1')
	else:
		print(li[y - 1])
	n = sys.stdin.readline()


import bisect
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
found = False
if k > n // 2:
	for i in reversed(a):
		if bisect.bisect_right(a, i) == k:
			print(i)
			found = True
			break
		elif bisect.bisect_right(a, i) < k:
			break
	if found:
		pass
	else:
		print(-1)
else:
	for i in a:
		if bisect.bisect_right(a, i) == k:
			print(i)
			found = True
			break
		elif bisect.bisect_right(a, i) > k:
			break
	if found:
		pass
	elif k == 0 and min(a) > 1:
		print(min(a) - 1)
	else:
		print(-1)


def solve(n: int, k: int, A: list):
	A.sort()
	if k == 0 and A[0] == 1:
		print(-1)
	elif k == 0 and A[0] > 1:
		print(1)
	elif n == k:
		print(1000000000)
	elif A[k] > A[k - 1]:
		print(A[k - 1])
	else:
		print(-1)
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
solve(n, k, A)


(n, k) = map(int, input().split())
ls = list(map(int, input().split()))
ls.sort()
if n == k:
	ans = ls[-1]
elif k == 0 and ls[0] > 1:
	ans = ls[0] - 1
elif k == 0:
	ans = -1
elif n == 1 and k == 1:
	ans = ls[0]
elif ls[k] == ls[k - 1]:
	ans = -1
else:
	ans = ls[k - 1]
if ans > 0 and ans <= pow(10, 9):
	print(ans)
else:
	print(-1)


import sys
import array
if __name__ == '__ONLINE_JUDGE__':
	sys.stdin = open('test.inp', 'r')
	sys.stdout = open('test.out', 'w')
(n, k) = [int(x) for x in input().split()]
a = array.array('i', [int(x) for x in input().split()])
a = sorted(a)
if k == 0:
	if a[0] == 1:
		print(-1)
		sys.exit()
	else:
		print(a[0] - 1)
		sys.exit()
k -= 1
if k == n - 1:
	print(a[k])
	sys.exit()
elif a[k] == a[k + 1]:
	print(-1)
	sys.exit()
else:
	print(a[k])
	sys.exit()


def main():
	nk = list(map(int, input().split()))
	x = list(map(int, input().split()))
	x.sort()
	if nk[1] == 0:
		if x[0] - 1 < 1:
			print(-1)
		else:
			print(x[0] - 1)
	elif nk[1] < len(x) and x[nk[1] - 1] == x[nk[1]]:
		print(-1)
	else:
		print(x[nk[1] - 1])
main()


(a, b) = input().split()
a = int(a)
b = int(b)
li = [int(i) for i in input().split()]
li.sort()
if b == 0:
	if li[0] == 1:
		print(-1)
	else:
		print(1)
elif a == 1:
	if li[0] == 1:
		print(-1)
	else:
		print(li[0])
elif b == a:
	print(li[b - 1])
elif li[b - 1] == li[b]:
	print(-1)
else:
	print(li[b - 1])


nk = list(map(int, input().split()))
seq = list(map(int, input().split()))
seq.sort()
k = nk[1]
if k != 0:
	x = seq[k - 1]
if k == 0:
	if seq[0] > 1:
		print(1)
	else:
		print(-1)
elif k < nk[0]:
	if seq[k - 1] == seq[k]:
		print(-1)
	else:
		print(x)
else:
	print(x)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
c = 0
if not k:
	if a[0] <= 1:
		print(-1)
	else:
		print(1)
	sys.exit(0)
ans = a[k - 1]
for i in a:
	if i <= ans:
		c += 1
if c > k:
	print(-1)
else:
	print(ans)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
lst = sorted(lst, reverse=False)
if k == 0:
	if min(lst) == 1:
		print(-1)
	else:
		print(1)
else:
	try:
		if lst[k - 1] == lst[k]:
			print(-1)
		else:
			print(lst[k - 1])
	except:
		print(lst[k - 1])


def less_or_equal(n, k, sequence):
	sequence.sort()
	if k == 0:
		val = sequence[k] - 1
		if val == 0:
			output = -1
		else:
			output = val
	elif k == n or sequence[k] != sequence[k - 1]:
		output = sequence[k - 1]
	else:
		output = -1
	if output > 10 ** 9:
		print(10 ** 9)
	else:
		print(output)
raw = input()
inp = raw.strip().split()
n = int(inp[0])
k = int(inp[1])
seq = input()
temp = seq.split()
for i in range(n):
	temp[i] = int(temp[i])
less_or_equal(n, k, temp)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
c = 0
ans = 0
if k == 0:
	ans = a[0] - 1
else:
	ans = a[k - 1]
for i in range(0, len(a)):
	if a[i] <= ans:
		c += 1
if c != k or ans < 1:
	print(-1)
else:
	print(ans)


t = list(map(int, input().split()))
s = list(map(int, input().split()))
s.sort()
if t[1] == 0:
	ans = s[0] - 1
else:
	ans = s[t[1] - 1]
cnt = 0
for i in range(t[0]):
	if s[i] <= ans:
		cnt += 1
if cnt != t[1] or ans < 1:
	print(-1)
else:
	print(ans)


(k, ls) = (list(map(int, input().split(' ')))[1], sorted(list(map(int, input().split(' ')))))
print((ls[k - 1] if k > 0 else ls[k] - 1) if not (k == 0 and ls[0] == 1) and (k == len(ls) or ls[k - 1] != ls[k]) or (k == 0 and ls[0] > 1) else -1)


import sys
nk = list(map(int, sys.stdin.readline().split()))
n = nk[0]
k = nk[1]
r = list(map(int, sys.stdin.readline().split()))
r.sort()
if k == 0:
	if r[0] == 1:
		print('-1')
	else:
		print('1')
	exit(0)
if n == k:
	print(r[-1])
	exit(0)
mx1 = r[k - 1]
if r[k] != r[k - 1]:
	print(mx1)
	exit(0)
else:
	print('-1')
	exit(0)


from sys import stdin

def main():
	(n, k) = map(int, stdin.readline().split())
	ar = list(map(int, stdin.readline().split()))
	ar.sort()
	if k == 0:
		if ar[0] == 1:
			print(-1)
		else:
			print(ar[0] - 1)
	else:
		curr = ar[k - 1]
		ind = k - 1
		for i in range(k, n):
			if ar[i] == curr:
				ind += 1
		if ind > k - 1:
			print(-1)
		else:
			print(curr)
main()


def problemC(n, k, a):
	if k == n:
		return max(a)
	a.sort()
	if k == 0:
		if a[0] == 1:
			return -1
		elif a[0] > 1:
			return 1
	if k <= n - 1:
		if a[k] == a[k - 1]:
			return -1
		else:
			return a[k - 1]
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
print(problemC(n, k, a))


def less_or_equal(n, k, a):
	a.sort()
	if k == 0:
		xmin = 1
		xmax = a[0] - 1
	elif k == n:
		xmin = a[-1]
		xmax = 1000000000
	else:
		xmin = a[k - 1]
		xmax = a[k] - 1
	if xmin > xmax:
		print('-1')
		return
	print(xmin)
(n, k) = [int(num) for num in input('').split(' ')]
a = [int(num) for num in input('').split(' ')]
less_or_equal(n, k, a)


def to_int(string):
	output = string.split()
	for i in range(len(output)):
		output[i] = int(output[i])
	return output

def main():
	general = to_int(input())
	n = general[0]
	k = general[1]
	array = sorted(to_int(input()))
	x = -1
	if k == 0:
		x = min(array) - 1
	elif k == n:
		x = max(array)
	else:
		x = array[k - 1]
		if array[k] == x:
			x = -1
	if not 1 <= x <= pow(10, 9):
		x = -1
	print(x)
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
from collections import Counter
counti = Counter(a)
l = list(counti.keys())
l.sort()
p = True
while p:
	summ = 0
	t = 0
	for (count, ele) in enumerate(l):
		if k == summ:
			t = 1
			if ele != 1:
				print(ele - 1)
			else:
				print('-1')
			break
		if k < summ:
			t = 1
			print('-1')
			break
		summ += counti[ele]
		if k == summ:
			t = 1
			print(ele)
			break
		if k < summ:
			t = 1
			print('-1')
			break
	p = False
	if t == 0:
		print('-1')


(n, k) = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
if k == n:
	print(a[-1])
elif k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(a[0] - 1)
else:
	(p, q) = (a[k - 1], a[k])
	if p != q:
		print(p)
	else:
		print(-1)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
if k == 0:
	if a[0] == 1:
		print(-1)
		quit()
	else:
		print(1)
		quit()
b = [[a[0], 1]]
prev_value = a[0]
count = 1
for i in range(1, len(a)):
	if prev_value != a[i]:
		b.append([a[i], 1])
		count = 1
		prev_value = a[i]
	else:
		b[-1][1] += 1
count = 0
for i in range(len(b)):
	count += b[i][1]
	if count == k:
		print(b[i][0])
		quit()
	elif count > k:
		print(-1)
		quit()
print(-1)


f = input().split(' ')
n = int(f[0])
k = int(f[1])
a = input().split(' ')
for i in range(0, n):
	a[i] = int(a[i])
a_updated = sorted(a)
if n <= k:
	print(a_updated[-1])
elif k != 0 and len(a_updated) > 1:
	if a_updated[k - 1] == a_updated[k]:
		print(-1)
	else:
		print(a_updated[k - 1])
elif k != 0 and len(a_updated) == 1:
	if a_updated[0] != 1:
		print(a_updated[0])
	else:
		print(-1)
elif k == 0:
	if a_updated[0] != 1:
		print(a_updated[0] - 1)
	else:
		print(-1)
else:
	print(a_updated[k - 1])


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
a.append(10 ** 9 + 1)
if k == 0 and a[0] == 1 or a[k - 1] == a[k]:
	print(-1)
elif k == 0:
	print(1)
else:
	print(a[k - 1])


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	sa = sorted(a)
	(l, r) = (1, max(a))
	while l < r:
		mid = (l + r + 1) // 2
		cnt = 0
		for i in range(n):
			if a[i] <= mid:
				cnt += 1
		if cnt <= k:
			l = mid
		elif cnt > k:
			r = mid - 1
	temp = 0
	for i in range(n):
		if a[i] <= l:
			temp += 1
	if temp == k:
		print(l)
	else:
		print(-1)
main()


nk = list(map(int, input().rstrip().split()))
arr = list(map(int, input().rstrip().split()))
arr.sort()
count = 0
ans = 0
if nk[1] == 0:
	ans = arr[0] - 1
else:
	ans = arr[nk[1] - 1]
for i in arr:
	if i <= ans:
		count = count + 1
if not 1 <= ans <= 1000000000 or count != nk[1]:
	print(-1)
else:
	print(ans)


import heapq as hq

def main():
	(n, k) = [int(t) for t in input().split(' ')]
	arr = [int(t) for t in input().split(' ')]
	heap = []
	if k == 0:
		m = min(arr)
		if m - 1 <= 0:
			print(-1)
			return
		else:
			print(m - 1)
			return
	if k == n:
		print(max(arr))
		return
	for i in range(n):
		hq.heappush(heap, arr[i])
	val = -1
	valP = -1
	for i in range(k + 1):
		item = hq.heappop(heap)
		if i == k - 1:
			val = item
		if i == k:
			valP = item
	if val == valP:
		print(-1)
	else:
		print(val)
main()


(a, b) = [int(a) for a in input().split()]
list_num = [int(b) for b in input().split()]
g = sorted(list_num)
max = list_num[0]
if b == 0:
	if g[0] - 1 >= 1:
		print(g[0] - 1)
	else:
		print(-1)
else:
	k = g[b - 1]
	count_equal = 0
	for i in range(b, len(list_num)):
		if g[i] <= k:
			count_equal += 1
	if count_equal > 0:
		print(-1)
	if count_equal == 0:
		print(g[b - 1])


import sys
nk = input().split()
n = int(nk.pop(0))
k = int(nk.pop(0))
a = [int(i) for i in input().split()]
a.sort()
a = a + (250000 - n) * [int]
ans = -1
if k > 0:
	if a[k - 1] != a[k]:
		ans = a[k - 1]
elif a[0] > 1:
	ans = a[0] - 1
print(ans)


(n, m) = map(int, input().split())
list1 = list(map(int, input().split()))
u = [1] + sorted(list1)
if m == n or u[m + 1] - u[m]:
	print(u[m])
else:
	print(-1)


temp = map(int, input().split())
(n, k) = temp
a = sorted(list(map(int, input().split())))
x = a[k - 1]
if k > 0:
	if k < n and a[k] == a[k - 1]:
		x = -1
elif a[0] > 1:
	x = 1
else:
	x = -1
print(x)


(noi, k) = [int(x) for x in input().split()]
seq = sorted([int(x) for x in input().split()])
if k > 0:
	if k < noi and seq[k - 1] == seq[k]:
		print(-1)
	else:
		print(seq[k - 1])
else:
	x = seq[0] - 1
	print(x if x > 0 else -1)


def less_or_equal(A, n, k):
	A = sorted(A)
	if k == 0:
		if A[0] == 1:
			print(-1)
		else:
			print(1)
	elif k < n and A[k - 1] == A[k]:
		print(-1)
	else:
		print(A[k - 1])
(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
less_or_equal(arr, n, k)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(n, k) = iia()
arr = sorted(iia())
if k == 0 and arr[0] > 1:
	print(arr[0] - 1)
elif k > 0 and k < n and (arr[k - 1] != arr[k]):
	print(arr[k - 1])
elif k == n:
	print(arr[-1])
else:
	print(-1)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a = sorted(a)
flag = 0
if k == 0:
	if a[0] == 1:
		print(-1)
		flag = 1
	else:
		print(1)
		flag = 1
elif k == n:
	print(a[n - 1])
elif a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k - 1])


T = input().split(' ')
n = int(T[0])
k = int(T[1])
S = input().split(' ')
for i in range(n):
	S[i] = int(S[i])
S.sort()
j = 0
nb = -1
bol = False
while j < n:
	if S[j] != nb and j == k:
		if S[j] - 1 >= 1:
			print(S[j] - 1)
			bol = True
		break
	nb = S[j]
	j += 1
if not bol:
	if k == n:
		print(S[n - 1])
	else:
		print(-1)


(n, k) = (int(x) for x in input().split())
array = list(map(int, input().split()))
array.sort()
if k == 0:
	if array[0] >= 2:
		print(array[0] - 1)
	else:
		print(-1)
	exit()
if k == n:
	print(array[k - 1])
	exit()
if array[k - 1] != array[k]:
	print(array[k - 1])
else:
	print(-1)


from collections import Counter
(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
if not k:
	if min(a) > 1:
		print(1)
	else:
		print(-1)
	exit(0)
cnt = Counter(a)
already = 0
for (num, v) in sorted(cnt.items()):
	already += v
	if already == k:
		print(num)
		exit(0)
print(-1)


def getAnswer(n, k, numL):
	cnt = 0
	F = False
	num = -1
	for i in numL:
		if F:
			if int(i) == num:
				return -1
		cnt = cnt + 1
		if cnt == k:
			num = int(i)
			F = True
	if num != -1:
		return num
	elif k == 0 and numL[0] != 1:
		return 1
	else:
		return -1
inputString = input()
(n, k) = inputString.split(' ')
inputString = input()
numberList = inputString.split(' ')
numL = []
for i in numberList:
	numL.append(int(i))
print(getAnswer(int(n), int(k), sorted(numL)))


R = lambda : map(int, input().split())
(n, k) = R()
L = sorted(R())
if n == 1:
	if k == 1:
		print(L[0])
		quit()
	elif L[0] == 1:
		print(-1)
		quit()
	else:
		print(L[0] - 1)
		quit()
if k == 0:
	if L[0] == 1:
		print(-1)
	else:
		print(L[0] - 1)
elif k == n:
	print(L[n - 1])
elif L[k - 1] == L[k]:
	print(-1)
else:
	print(L[k - 1])


def convert_into_int(arr):
	for i in range(len(arr)):
		arr[i] = int(arr[i])
	return arr

def compute_x(arr, k):
	arr.sort()
	z = k - 1
	x = arr[z]
	if k == 0:
		if len(arr) != 0:
			if arr[0] != 1:
				return 1
			else:
				return -1
	if k != len(arr):
		if arr[k] == arr[z]:
			return -1
	return x
k = int(input().split(' ')[1])
input_data = convert_into_int(input().split(' '))
print(compute_x(input_data, k))


(n, k) = map(int, input().split())
lis = list((int(num) for num in input().strip().split()))[:n]
lis.sort()
res = -1
if k >= n:
	res = 1000000000
elif k == 0:
	if lis[0] > 1:
		res = 1
elif lis[k] > lis[k - 1]:
	res = lis[k - 1]
print(res)


(n, k) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
arr.sort(reverse=False)
ans = -1
count = 1
if k == 0:
	ans = arr[0] - 1
for i in range(n):
	if k == count:
		if i + 1 < n:
			if arr[i] != arr[i + 1]:
				ans = arr[i]
			else:
				ans = -1
		else:
			ans = arr[i]
		break
	count += 1
if not (ans >= 1 and ans <= 1000 * 1000 * 1000):
	ans = -1
print(ans)


(n, k) = [int(i) for i in input().split(' ')]
nums = [int(i) for i in input().split(' ')]
nums = list(sorted(nums))
if k == 0:
	if nums[k] == 0 or nums[k] == 1:
		print(-1)
	else:
		print(1)
elif n == k:
	print(nums[k - 1])
elif nums[k - 1] < nums[k]:
	print(nums[k - 1])
else:
	print(-1)


def lessorequal(n, k, a):
	a.sort()
	a.append(0)
	if k == 0:
		if a[0] == 1:
			return -1
		else:
			return 1
	elif a[k - 1] == a[k]:
		return -1
	else:
		return a[k - 1]
(n, k) = input().strip().split()
a = input().strip().split()
a = list(map(int, a))
print(lessorequal(int(n), int(k), a))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
s = l[k - 1]
if k != 0:
	if s not in l[k:]:
		print(s)
	else:
		print(-1)
elif l[0] != 1:
	print(l[0] - 1)
else:
	print(-1)


(n, k) = input().split()
k = int(k)
n = int(n)
x = [int(i) for i in input().split()]
x.sort()
z = x[:k]
if k == 0:
	if 1 < x[0]:
		print(1)
	else:
		print(-1)
elif k == n:
	print(max(x))
else:
	f = max(z) + 1
	if f < x[k]:
		print(f)
	elif f >= x[k]:
		if f - 1 < x[k]:
			print(f - 1)
		else:
			print(-1)


def loe(ns, k):
	ns = sorted(ns)
	if k == 0:
		return 1 if ns[0] != 1 else -1
	elif k < len(ns) and ns[k - 1] == ns[k]:
		return -1
	else:
		return ns[k - 1]
k = int(input().split()[1])
ns = list(map(int, input().split()))
print(loe(ns, k))


from bisect import bisect_left as bl
(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
ele = a[k - 1]
if k == 0:
	if min(a) - 1 > 0:
		print(min(a) - 1)
	else:
		print(-1)
elif k - 1 != n - 1 and a[k - 1] == a[k]:
	print(-1)
elif k - 1 == n - 1:
	if ele <= 10 ** 9:
		print(ele)
	else:
		print(-1)
else:
	print(ele)


(n, k) = map(int, input().strip().split(' '))
L = list(map(int, input().split(' ')))
L = sorted(L)
if k == 0:
	if L[k] != 1:
		print(L[k] - 1)
	else:
		print(-1)
elif k < n:
	if L[k - 1] == L[k]:
		print(-1)
	else:
		print(L[k - 1])
elif L[k - 1] <= 10 ** 9:
	print(L[k - 1])
else:
	print(-1)


def check(x, arr, k):
	count = 0
	for i in arr:
		if i <= x:
			count += 1
	if count >= k:
		return True
	return False

def main():
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	low = 1
	high = 10 ** 9
	x = -1
	while low <= high:
		mid = (low + high) // 2
		if check(mid, arr, k):
			high = mid - 1
			x = mid
		else:
			low = mid + 1
	if x == -1:
		print(x)
		return
	count = 0
	for i in arr:
		if i <= x:
			count += 1
	if count == k:
		print(x)
	else:
		print(-1)
main()


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
l = 1
r = 1000000001
while r - l > 1:
	m = (l + r) // 2
	cnt = 0
	for i in range(n):
		if a[i] <= m:
			cnt += 1
	if cnt > k:
		r = m
	else:
		l = m
cntt = 0
for i in range(n):
	if a[i] <= l:
		cntt += 1
if cntt == k:
	print(l)
else:
	print(-1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.append(1)
a.append(1000000001)
b = sorted(a)
x = b[k] if b[k] != b[k + 1] else -1
print(x)


(n, k) = map(int, input().split())
sequence = [int(s) for s in input().split()]
sequence.sort()
if k > 0:
	if k < n and sequence[k - 1] == sequence[k]:
		print(-1)
	else:
		print(sequence[k - 1])
elif sequence[0] > 1:
	print(sequence[0] - 1)
else:
	print(-1)


(n, k) = input().split(' ')
k = int(k)
sequence = [int(a) for a in input().split(' ')]
sequence = sorted(sequence)
if k == 0:
	if sequence[0] > 1:
		print(sequence[0] - 1)
	else:
		print(-1)
elif k == int(n) or sequence[k - 1] != sequence[k]:
	print(sequence[k - 1])
else:
	print(-1)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import PriorityQueue as pq
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if k == n:
	print(l[-1])
elif k == 0:
	if l[0] > 1:
		print(l[0] - 1)
	else:
		print(-1)
elif k > n or (k < n and l[k - 1] == l[k]):
	print(-1)
else:
	print(l[k - 1])


(m, n) = map(int, input().split())
a = sorted(list(map(int, input().split())))
a.append(-1)
d = 0
if n == 0 and a[0] > 1:
	print(a[0] - 1)
elif m == n:
	print(a[m - 1])
elif a[n - 1] == a[n]:
	print(-1)
else:
	print(a[n - 1])


(n, k) = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
if n == k:
	ans = nums[-1]
elif k == 0:
	if nums[0] == 1:
		ans = -1
	else:
		ans = 1
elif nums[k - 1] == nums[k]:
	ans = -1
else:
	ans = nums[k - 1]
print(ans)


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
(n, k) = map(int, input().split())
arr = input().split()
arr.sort(key=int)
if k > 0 and (k == n or int(arr[k - 1]) != int(arr[k])):
	print(arr[k - 1])
elif k == 0 and int(arr[0]) != 1:
	print(1)
else:
	print(-1)


s = input().split()
(n, k) = (int(s[0]), int(s[1]))
cl = sorted(list(map(int, input().split())))
if k > n:
	print(-1)
elif k == n:
	print(cl[-1])
elif k == 0:
	if cl[0] - 1 < 1:
		print(-1)
	else:
		print(cl[0] - 1)
elif n == 1:
	print(cl[0])
elif cl[k - 1] == cl[k]:
	print(-1)
else:
	print(cl[k - 1])


def main():
	(n, m) = map(int, input().split())
	a = sorted(map(int, input().split()))
	a = [a[0] - 1, *a, a[-1] + 1]
	print(min(a[m], 10 ** 9) if 0 < a[m] < a[m + 1] else -1)
main()


(n, k) = map(int, input().split())
array = list(sorted(map(int, input().split())))
if k == n:
	array.append(array[k - 1])
else:
	array.insert(k, array[k] - 1)
if k == 0:
	print(array[0] if array[0] >= 1 and array.count(array[0]) == 1 else -1)
else:
	print(array[k] if array[k] >= array[k - 1] else -1)


(n, k) = map(int, input().split())
l = [int(i) for i in input().split()]
if k == 0:
	print(1 if 1 not in l else -1)
	exit()
l.sort()
if n == k:
	print(l[k - 1])
elif l[k - 1] == l[k]:
	print(-1)
else:
	print(l[k - 1])


import sys, math
(n, k) = map(int, sys.stdin.readline().split())
liste = list(map(int, sys.stdin.readline().split()))
liste.sort()
if k == 0 and liste[0] - 1 > 0:
	print(1)
elif k == 0 or (k <= n - 1 and liste[k - 1] == liste[k]):
	print(-1)
else:
	print(liste[k - 1])


def rr():
	return input().rstrip()

def rri():
	return int(rr())

def rrl():
	return list(map(int, rr().split()))

def rrt():
	return tuple(map(int, rr().split()))
from collections import defaultdict

def mus(d=0):
	return defaultdict(defaultdict(d))

def ms(x, y, d=0):
	return [[0] * y for i in range(x)]

def ar(x, d=0):
	return [d] * x

def ppm(m, n=0, x=0, y=0):
	print('\n'.join(('\t'.join((str(m[j][i]) for j in range(y or n))) for i in range(x or n))))

def ppa(a, n):
	print('\t'.join(map(str, a[0:n])))

def ppl(a=0, x=[1]):
	x[0] = a or x[0] + 1
	print('-' + '- -' * 14 + '-# ' + str(x[0] - 2) + ' #-' + '- -' * 14 + '-')

def yn(x):
	return 'YES' if x else 'NO'
from itertools import accumulate
from itertools import groupby

def grp(x):
	return ((i, sum((1 for _ in g))) for (i, g) in groupby(x))
import math

def rnar():
	return (*rrl(), rrl())

def read():
	return rnar()

def solve(n, k, arr):
	arr.sort()
	cur_am = 0
	for (i, g_am) in grp(arr):
		cur_am += g_am
		if cur_am == k:
			ans = i
			break
		elif cur_am > k:
			ans = -1
			break
	if k == 0 and arr[0] == 1:
		ans = -1
	elif k == 0 and arr[0] > 1:
		ans = 1
	return ans
test_count = 1
for _ in range(test_count):
	input_data = read()
	result = solve(*input_data)
	print(result)


(n, k) = map(int, input().split())
list1 = list(map(int, input().split()))
list1.sort()
if k == 0:
	m = list1[0] - 1
else:
	m = list1[k - 1]
cnt = 0
for i in list1:
	if m >= i:
		cnt += 1
if k != cnt or m < 1:
	print(-1)
else:
	print(m)


from collections import Counter
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
if k == 0:
	if sorted(a)[0] > 1:
		print(1)
	else:
		print(-1)
	exit(0)
cnt = Counter(a)
ans = 0
for cur in sorted(cnt):
	ans += cnt[cur]
	if ans == k:
		print(cur)
		break
	elif ans > k:
		print(-1)
		break


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
x = A[K - 1]
lim = 10 ** 9
if K == 0:
	if A[0] == 1:
		print('-1')
	else:
		print(A[0] - 1)
elif N == K:
	print(A[-1])
elif A[K - 1] != A[K]:
	print(x)
else:
	print('-1')


(n, k) = map(int, input().split(' '))
arr1 = sorted(list(map(int, input().split(' '))))

def main(arr):
	global n, k
	if len(arr) == 1:
		if k == 1:
			return arr[0]
		if k > 1:
			return -1
	if k == 0:
		j = arr[0] - 1
		if j <= 0:
			return -1
		return j
	if len(arr) == k:
		return arr[-1]
	if arr[k - 1] == arr[k]:
		return -1
	return arr[k - 1]

def c(m):
	if 1 <= m and m <= 1000000000:
		return m
	else:
		return -1
print(c(main(arr1)))


nk = [int(j) for j in input().split(' ')]
n = nk[0]
k = nk[1]
numbers = [int(i) for i in input().split(' ')]
numbers.sort()
if n == k:
	print(numbers[n - 1])
elif k == 0:
	print('-1') if numbers[0] == 1 else print('1')
elif numbers[k - 1] == numbers[k]:
	print('-1')
else:
	print(numbers[k - 1])


from sys import stdin, stdout
from collections import defaultdict, Counter
from bisect import bisect, bisect_left
import math
I = stdin.readline
(n, k) = map(int, I().split())
arr = [int(x) for x in I().split()]
arr.sort()
if k == 0 and arr[0] == 1:
	print(-1)
elif k == 0:
	print(arr[0] - 1)
elif k == n:
	print(arr[-1])
else:
	c = arr[k - 1]
	if c == arr[k]:
		print(-1)
	else:
		print(c)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if k == 0:
	if x[0] <= 1:
		print(-1)
	else:
		print(1)
elif k < n:
	if x[k] != x[k - 1]:
		print(x[k] - 1)
	else:
		print(-1)
elif k == n:
	print(10 ** 9)


def f(lst, x):
	count = 0
	for i in range(len(lst)):
		if lst[i] <= x:
			count += 1
	return count

def bin_search(k, lst, left_bound, right_bound):
	while left_bound <= right_bound:
		middle = (left_bound + right_bound) // 2
		f_cur = f(lst, middle)
		if k == f_cur:
			return middle
		elif k < f_cur:
			right_bound = middle - 1
		else:
			left_bound = middle + 1
	return -1
(n, k) = [int(j) for j in input().split()]
a = [int(i) for i in input().split()]
print(bin_search(k, a, 1, 10 ** 9))


from collections import *
(n, k) = map(int, input().split())
nums = [int(x) for x in input().split()]
if n == k:
	print(max(nums))
elif k == 0:
	temp = min(nums)
	if temp == 1:
		print(-1)
	else:
		print(temp - 1)
else:
	nums.sort()
	if nums[k - 1] == nums[k]:
		print(-1)
	else:
		print(nums[k - 1])


def solve(n, k, a):
	if n == 1:
		if k == 0:
			if a[0] == 1:
				return -1
			else:
				return a[0] - 1
		if k == 1:
			return a[0]
	if n > 1:
		if k == 0:
			return a[0] - 1 if a[0] > 1 else -1
		if k >= 1:
			if k == n:
				return a[k - 1]
			elif a[k] == a[k - 1]:
				return -1
			else:
				return a[k - 1]
(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
print(solve(n, k, a))


((n, k), a) = (map(int, input().split()), sorted(list(map(int, input().split()))))
(cnt, d) = (0, dict())
for i in a:
	d[i] = d.get(i, 0) + 1
a = sorted([i for i in d.items()])
for i in a:
	if cnt == k and i[0] != 1:
		print(i[0] - 1)
		exit(0)
	if cnt > k:
		print(-1)
		exit(0)
	cnt += i[1]
print(a[-1][0] if cnt == k else -1)


string = input().split()
n = int(string[0])
k = int(string[1])
list = input().split()
for i in range(n):
	list[i] = int(list[i])
list.sort()
if k == 0:
	if list[k] - 1 < 1:
		print(-1)
	else:
		print(list[k] - 1)
elif k == n:
	print(list[k - 1])
elif list[k - 1] == list[k]:
	print(-1)
else:
	print(list[k - 1])


from bisect import bisect_right as br
(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
if k == 0:
	print(1 if a[0] >= 2 else -1)
else:
	print(a[k - 1] if br(a, a[k - 1]) == k else -1)


(n, k) = map(int, input().split())
array = list(map(int, input().split()))
array.sort()
x = -1
if k > 0:
	if k < len(array) and array[k] != array[k - 1]:
		x = array[k - 1]
	elif k == len(array):
		x = array[k - 1]
elif array[0] > 1:
	x = 1
print(x)


a = input()
(n, k) = a.split(' ')
k = int(k)
n = int(n)
b = input()
b = b.split(' ')
b = list(map(int, b))
b = sorted(b)
if max(b) > 10 ** 9 or min(b) < 1 or n > 2 * 10 ** 5:
	print(-1)
elif n > k:
	if k == 0:
		if b[0] - 1 > 0:
			print(b[0] - 1)
		else:
			print(-1)
	elif b[k] > b[k - 1]:
		print(b[k] - 1)
	elif b[k - 2] == b[k - 1] and b[k - 1] != b[k]:
		print(b[k - 1])
	else:
		print(-1)
elif k == n:
	print(b[-1])


(a, b) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
x = arr[b - 1]
if b == 0:
	if arr[0] == 1:
		print(-1)
	else:
		print(1)
elif a == b:
	print(arr[-1])
else:
	y = arr[b]
	if x < y - 1:
		print(x + 1)
	elif x != y:
		print(x)
	else:
		print(-1)


(n, k) = map(int, input().split())
a = list(sorted(map(int, input().split())))
x = -1
if k == 0:
	x = max(1, a[0] - 1)
else:
	x = a[k - 1]
s = 0
for i in range(n):
	s += a[i] <= x
if s == k:
	print(x)
else:
	print(-1)


import operator
data = input().split(' ')
n = int(data[0])
k = int(data[1])
data = map(int, input().split(' '))
sorted_data = sorted(data)
if k == 0:
	result = sorted_data[0] - 1 if sorted_data[0] - 1 > 0 else -1
	print(result)
	exit()
result = sorted_data[k - 1]
check = sum((1 for i in sorted_data if i <= result))
if check != k:
	print('-1')
else:
	print(result)


(n, k) = input().split()
n = int(n)
k = int(k)
a = [int(i) for i in input().split()]
a = sorted(a)
res = 0
if n == 1:
	if k == 0:
		res = a[0] - 1
	else:
		res = a[0]
elif k == 0:
	res = a[0] - 1
elif k == n:
	res = a[k - 1]
elif a[k] == a[k - 1]:
	res = -1
else:
	res = a[k - 1]
if res == 0 or res > 10 ** 9:
	print(-1)
else:
	print(res)


(N, K) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if N == K:
	print(a[K - 1])
elif K == 0 and a[0] != 1:
	print(1)
elif a[K - 1] < a[K]:
	print(a[K - 1])
else:
	print(-1)


def make_int(num):
	return int(num)

def check_x(x):
	if x >= 1 and x <= int(1000000000.0):
		return x
	else:
		return -1
num = input().split()
k = make_int(num[1])
num = make_int(num[0])
arr = []
arr = input().split()
arr = list(map(make_int, arr))
arr.sort()
x = -1
if k < num:
	if k != 0:
		if arr[k - 1] + 1 <= arr[k]:
			x = arr[k - 1]
	else:
		x = arr[0] - 1
elif k == num:
	x = arr[k - 1]
x = check_x(x)
print(x)


from collections import Counter
import string
import math
import sys
from fractions import Fraction

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
testcases = 1
for _ in range(testcases):
	(n, k) = vary(2)
	num = array_int()
	num.sort()
	if k == 0:
		if num[0] == 1:
			print(-1)
		else:
			print(1)
	elif k == n:
		print(10 ** 9)
	elif num[k] - num[k - 1] == 0:
		print(-1)
	else:
		print(num[k - 1])


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
if k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(a[0] - 1)
elif k == n:
	print(a[-1])
else:
	theitem = a[k - 1]
	if a[k - 1] != a[k]:
		print(a[k - 1])
	else:
		print(-1)


n = 0
k = 0
x = 0
l = []
(n, k) = input().split()
n = int(n)
k = int(k)
l = input().split()
for i in range(n):
	l[i] = int(l[i])
l.sort()
if k == 0:
	if l[0] > 1:
		print(l[0] - 1)
	else:
		print(-1)
elif k == n:
	print(l[k - 1])
elif l[k] - l[k - 1] > 0:
	print(l[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
s = input()
a = [int(i) for i in s.split()]
a.sort()
a.append(-1)
if k == 0 and a[0] != 1:
	print(1)
elif a[k - 1] != a[k]:
	print(a[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
if k == 0:
	ans = a[0] - 1
else:
	ans = a[k - 1]
c = 0
for i in a:
	if i <= ans:
		c += 1
if c != k or not 1 <= ans <= 10 ** 9:
	print('-1')
	exit(0)
print(ans)


(i_liczb, k) = map(int, input().split())
liczby = [int(x) for x in input().split()]
liczby.sort()
odp = 0
if k == 0:
	odp = liczby[0] - 1
else:
	odp = liczby[k - 1]
cos = 0
for x in liczby:
	if x <= odp:
		cos += 1
	else:
		break
if odp < 1 or cos != k:
	print(-1)
else:
	print(odp)


def test_2():
	import math
	from collections import Counter
	(n, k) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	a.sort()
	if k == 0:
		c = a[0]
		if c <= 1:
			print(-1)
		else:
			print(1)
	elif k == n:
		print(a[k - 1])
	elif a[k] == a[k - 1]:
		print(-1)
	else:
		print(a[k - 1])
test_2()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if l[0] == 1 and k == 0:
	print(-1)
elif k == 0:
	print(l[0] - 1)
elif k == n:
	print(l[k - 1])
elif l[k] == l[k - 1]:
	print(-1)
else:
	print(l[k - 1])


import sys
header = sys.stdin.readline()
while header:
	(n, k) = [int(x) for x in header.split()]
	seq = sorted([int(s) for s in sys.stdin.readline().split()])
	if k == 0:
		if seq[0] <= 1:
			print(-1)
		else:
			print(seq[0] - 1)
	elif n == 1:
		print(seq[0])
	elif n == k:
		print(seq[-1])
	elif seq[k - 1] != seq[k]:
		print(seq[k - 1])
	else:
		print(-1)
	header = sys.stdin.readline()


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
s = 0
if b == 0:
	l = c[0] - 1
else:
	l = c[b - 1]
for i in c:
	if i <= l:
		s += 1
if s != b or not 10 ** 9 >= l >= 1:
	print(-1)
else:
	print(l)


from sys import stdin, stdout
import math
(N, K) = [int(x) for x in stdin.readline().split()]
arr = [int(x) for x in stdin.readline().split()]
arr.sort()
count = 0
c = {}
num = []
for i in range(N):
	if arr[i] not in c:
		count = 1
		num.append(arr[i])
	else:
		count += 1
	c[arr[i]] = count
s = 0
if K == 0 and num[0] == 1:
	print(-1)
	quit()
elif K == 0 and num[0] > 1:
	print(1)
	quit()
for key in num:
	s += c[key]
	if s == K:
		print(key)
		quit()
print(-1)


(n, k) = map(int, input().split())
ar = list(map(int, input().split())) + [1]
ar = sorted(ar)
if n == k or ar[k + 1] != ar[k]:
	print(ar[k])
else:
	print(-1)


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
x = n - 1 - a[::-1].index(a[k - 1])
print([a[k - 1], -1][x != k - 1]) if k != 0 else print([1, -1][1 in a])


firstLine = input().split(' ')
n = int(firstLine[0])
k = int(firstLine[1])
array = input().split(' ')
array = [int(x) for x in array]
array.sort()
if k == 0:
	if array[k] - 1 == 0:
		print(-1)
	else:
		print(array[k] - 1)
elif k == n:
	print(array[n - 1])
elif array[k - 1] == array[k]:
	print(-1)
else:
	print(array[k - 1])


def get_median(l):
	n = len(l)
	if n % 2 == 1:
		return l[n // 2]
	else:
		return 0.5 * (l[n // 2 - 1] + l[n // 2])

def nlogn_median(l):
	l = sorted(l)
	return get_median(l)

def quickselect_median(l, pivot_fn):
	n = len(l)
	if n % 2 == 1:
		return quickselect(l, n // 2, pivot_fn)
	else:
		return 0.5 * (quickselect(l, n // 2 - 1, pivot_fn) + quickselect(l, n // 2, pivot_fn))

def quickselect(l, k, pivot_fn):
	if len(l) == 1:
		return l[0]
	pivot = pivot_fn(l)
	lows = [el for el in l if el < pivot]
	highs = [el for el in l if el > pivot]
	pivots = [el for el in l if el == pivot]
	if k < len(lows):
		return quickselect(lows, k, pivot_fn)
	elif k < len(lows) + len(pivots):
		return pivots[0]
	else:
		return quickselect(highs, k - len(lows) - len(pivots), pivot_fn)

def chunked(l, chunk_size):
	return [l[i:i + chunk_size] for i in range(0, len(l), chunk_size)]

def pick_pivot(l):
	if len(l) < 5:
		return nlogn_median(l)
	chunks = chunked(l, 5)
	sorted_groups = [sorted(chunk) for chunk in chunks]
	medians = [get_median(chunk) for chunk in sorted_groups]
	median_of_medians = quickselect_median(medians, pick_pivot)
	return median_of_medians
(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
MAXN = 1000000000
MINN = 1
if k == 0:
	minx = MAXN + 1
	for x in l:
		minx = min(minx, x)
	if minx == MINN:
		print(-1)
	else:
		print(minx - 1)
elif k == n:
	maxx = MINN - 1
	for x in l:
		maxx = max(maxx, x)
	print(maxx)
else:
	kth = quickselect(l, k - 1, pick_pivot)
	if kth > MAXN or kth < MINN:
		print(-1)
	else:
		cnt = 0
		for i in range(n):
			cnt += l[i] <= kth
		if cnt == k:
			print(kth)
		else:
			print(-1)


input_list = [int(i) for i in input().split() if int(i) <= 2 * 10 ** 5]
(seq_len, k) = (input_list[0], input_list[1])
seq = [int(i) for i in input().split()]
seq.sort()
if k != 0:
	if seq_len >= 2:
		if k < seq_len:
			if seq[k - 1] == seq[k]:
				print(-1)
			elif seq[k - 1] <= 10 ** 9:
				print(seq[k - 1])
		else:
			print(seq[k - 1])
	elif seq_len == 1:
		if k == 1:
			print(seq[0])
		elif k == 0:
			if seq[0] == 1:
				print(-1)
			else:
				print(seq[0] - 1)
elif seq[0] == 1:
	print(-1)
else:
	print(seq[0] - 1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
flag = 0
if k == 0:
	ans = a[0] - 1
else:
	ans = a[k - 1]
for i in range(n):
	if a[i] <= ans:
		flag += 1
if flag == k and ans > 0 and (ans < 10 ** 9 + 1):
	print(ans)
else:
	print(-1)


(n, k) = list(map(int, input().split()))
seq = list(map(int, input().split()))
seq.sort()
if k == 0:
	if seq[0] > 1:
		print(1)
	else:
		print(-1)
else:
	x = seq[k - 1]
	if k < n and seq[k] == seq[k - 1]:
		print(-1)
	else:
		print(x)


(n, k) = input().split(' ')
k = int(k)
arr = input().split(' ')
arr = sorted(list(map(lambda x: int(x), arr)))
if len(arr) < k:
	print(-1)
elif k == 0:
	guess = arr[0] - 1
	if guess > 1000000000 or guess < 1:
		print(-1)
	else:
		print(guess)
elif len(arr) > k and arr[k] - arr[k - 1] < 1:
	print(-1)
else:
	guess = arr[k - 1]
	if guess > 1000000000 or guess < 1:
		print(-1)
	else:
		print(guess)


(qtd, k) = list(map(int, input().split()))
lista = sorted(list(map(int, input().split())))
if k == 0:
	a = lista[0] - 1
else:
	a = lista[k - 1]
b = [x for x in lista if x <= a]
if len(b) != k or a < 1:
	print(-1)
else:
	print(a)


a = [int(i) for i in input().split()]
n = a[0]
k = a[1]
b = [int(i) for i in input().split()]
b.sort()
if k == 0 and b[0] == 1:
	print(-1)
elif k == 0:
	print(1)
elif n == 1:
	print(b[0])
elif k == n:
	print(b[n - 1])
elif b[k - 1] == b[k]:
	print(-1)
else:
	print(b[k - 1])


(n, k) = map(int, input().split())
seq = list(map(int, input().split()))
seq.sort()
ans = seq[0] - 1
count = 0
if k > 0 and k <= n:
	ans = seq[k - 1]
for i in range(n):
	if seq[i] <= ans:
		count += 1
	else:
		break
if ans < 1 or count != k:
	print('-1')
else:
	print(ans)


(n, k) = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
if k == 0 and a[0] == 1:
	print(-1)
elif k == 0 and a[0] > 1:
	print(a[0] - 1)
elif k == n:
	print(a[n - 1])
elif a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k - 1])


print((lambda x: (-1 if x[1][0] == 1 else 1) if x[0][1] == 0 else -1 if x[0][1] != x[0][0] and x[1][x[0][1] - 1] == x[1][x[0][1]] else x[1][x[0][1] - 1])((lambda x: (x[0], sorted(x[1])))(tuple(map(lambda x: list(map(int, x.split())), __import__('sys').stdin.read().split('\n'))))))


(n, k) = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
a.sort()
if k == 0:
	print(-1 + a[0] * (a[0] > 1))
	quit()
if a[k - 1] not in a[k:]:
	print(a[k - 1])
	quit()
print(-1)


(x, k) = map(int, input().split())
li = list(map(int, input().split()))
li.sort()
if k == x:
	print(li[x - 1])
elif k == 0 and x > 1:
	if li[0] != 1:
		print(li[0] - 1)
	else:
		print(-1)
elif k == 0:
	if li[0] != 1:
		print(li[0] - 1)
	else:
		print(-1)
elif li[k - 1] != li[k]:
	print(li[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
dic = {}
for i in range(n):
	dic[a[i]] = i
b = sorted(list(set(a)))
for q in b:
	if dic[q] + 1 == k:
		print(q)
		exit()
if k == 0:
	if min(a) != 1:
		print(1)
		exit()
print(-1)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
val = arr[k - 1]
if k == 0:
	if arr[0] == 1:
		print('-1')
	else:
		print(1)
elif k == n:
	print(val)
elif val == arr[k]:
	print('-1')
else:
	print(val)


import sys, math
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = 1
for tt in range(t):
	(n, k) = invr()
	a = inlt()
	a.sort()
	if k == 0:
		if a[0] == 1:
			print(-1)
		else:
			print(1)
		break
	if k != n and a[k - 1] == a[k]:
		print(-1)
	else:
		print(a[k - 1])


t = 1
while t:
	t -= 1
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	if k == 0:
		ans = a[0] - 1
	else:
		ans = a[k - 1]
	cnt = 0
	for el in a:
		if el <= ans:
			cnt += 1
		else:
			break
	if cnt == k and ans > 0:
		print(ans)
	else:
		print(-1)


import sys

def main():
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	assert len(a) == n
	a.sort()
	if k == 0:
		if a[0] == 1:
			print(-1)
			return 0
		else:
			print(a[0] - 1)
			return 0
	if k == n:
		print(int(1000000000.0))
		return 0
	if a[k - 1] == a[k]:
		print(-1)
		return 0
	print(a[k - 1])
main()


a = map(int, input().split())
b = map(int, input().split())
a = list(a)
b = list(b)
b.sort()
c = b[a[1] - 1]
if a[1] == 0:
	if b[0] == 1:
		print(-1)
	else:
		print(b[0] - 1)
elif a[0] == a[1]:
	print(c)
elif b[a[1]] == c:
	print(-1)
else:
	print(c)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if m == 0:
	print('-1' if l[0] == 1 else 1)
else:
	print(-1 if m < n and l[m - 1] == l[m] else l[m - 1])


(x, y) = [int(a) for a in input().split()]
z = [int(a) for a in input().split()]
z = sorted(z)
if y == 0 and z[0] > 1:
	print(1)
	quit()
elif y == 0 and z[0] == 1:
	print(-1)
	quit()
elif y <= x - 1:
	if z[y - 1] != z[y]:
		print(z[y - 1])
	else:
		print(-1)
elif x == y:
	print(z[y - 1])


(n, k) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
if k == 0:
	if l[0] - 1 < 1:
		print('-1')
	else:
		print(l[0] - 1)
elif k > n or (k < n and l[k] - l[k - 1] < 1):
	print('-1')
else:
	print(l[k - 1])


n_k = input().split()
n = int(n_k[0])
k = int(n_k[1])
k_elements = list()
numbers = list(map(int, input().split()))
numbers.sort()
if k == 0:
	if numbers[0] - 1 < 1:
		print(-1)
	else:
		print(numbers[0] - 1)
elif n == 1 or k == n:
	print(numbers[k - 1])
elif numbers[k] == numbers[k - 1]:
	print(-1)
else:
	print(numbers[k - 1])


alph = 'abcdefghijklmnopqrstuvwxyz'
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
p = k
if k == n:
	print(a[-1])
elif k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(1)
elif a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k - 1])


def main():
	(n, k) = [int(i_str) for i_str in input().split()]
	sequence = sorted([int(i_str) for i_str in input().split()])
	if k == 0:
		print(sequence[0] - 1 if sequence[0] > 1 else -1)
	elif 0 < k < n and sequence[k - 1] == sequence[k]:
		print(-1)
	else:
		print(sequence[k - 1])
main()


import sys
from bisect import bisect_left, bisect_right
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log
from itertools import permutations
inf = float('inf')
mod = 1000000007
mini = 1000000007

def fact(n):
	if n == 0:
		return 1
	p = 1
	d = 10 ** 9 + 7
	for i in range(1, n + 1):
		p = p * i
		p = p % d
	return p

def ncr(n, r):
	d = 10 ** 9 + 7
	num = fact(n)
	den = fact(r) * fact(n - r) % d
	den = pow(den, d - 2, d)
	return num * den % d

def sieve(n):
	prime = [True for i in range(n + 1)]
	lst = [0] * (n + 1)
	p = 2
	while p * p <= n:
		if prime[p]:
			lst[p] = p
			for i in range(p * p, n + 1, p):
				if prime[i] == True:
					prime[i] = False
					lst[i] = p
		p = p + 1
	for i in range(1, n + 1):
		if lst[i] == 0:
			lst[i] = i
	mylist = [0] * (n + 1)
	for i in range(2, n + 1):
		mylist[lst[i]] = mylist[lst[i]] + 1
	return mylist

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def calculate_factors(n):
	hh = [1] * (n + 1)
	p = 2
	while p * p < n:
		if hh[p] == 1:
			for i in range(p * 2, n, p):
				hh[i] = 0
		p += 1
	total = 1
	for p in range(2, n + 1):
		if hh[p] == 1:
			count = 0
			if n % p == 0:
				while n % p == 0:
					n = int(n / p)
					count += 1
				total *= count + 1
	return total

def prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.add(i)
	if n > 1:
		factors.add(n)
	if len(factors) == 2:
		return True
	else:
		return False

def isPrime(n):
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n < 2:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, k) = get_ints()
Arr = get_array()
Arr.sort()
if k == 0:
	ans = Arr[0] - 1
else:
	ans = Arr[k - 1]
count = 0
for i in range(n):
	if Arr[i] <= ans:
		count = count + 1
if ans < 1 or count != k:
	print(-1)
else:
	print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.append(0)
if m == 0 and a[0] > 1:
	print(1)
elif a[m - 1] == a[m] or m == 0:
	print(-1)
else:
	print(a[m - 1])


(n, k) = map(int, input().split())
mydict = []
a = sorted(list(map(int, input().split())))
l = -1
x = -1
for i in a:
	if i != l:
		x += 1
		l = i
		mydict.append([i, 1])
	else:
		mydict[x][1] += 1
l = 0
if k == 0:
	if mydict[0][0] != 1:
		print(1)
	else:
		print(-1)
else:
	for i in range(len(mydict)):
		if k - mydict[i][1] == 0:
			print(mydict[i][0])
			break
		elif k - mydict[i][1] > 0:
			k -= mydict[i][1]
		else:
			print(-1)
			break


import sys
(n, k) = map(int, sys.stdin.readline().strip().split())
a = sys.stdin.readline()

def findX(n, k, a):
	a = a.strip().split()
	a_dict = {}
	for num in a:
		try:
			a_dict[int(num)] += 1
		except:
			a_dict[int(num)] = 1
	a.sort()
	numbers = list(a_dict)
	numbers.sort()
	if k < 1:
		if numbers[0] < 2:
			return -1
		else:
			return 1
	moreThen = 0
	position = 0
	while moreThen < k and position < len(numbers):
		moreThen += a_dict[numbers[position]]
		position += 1
	if position < len(numbers) + 1:
		if moreThen == k:
			return numbers[position - 1]
	return -1

def doTest():
	assert findX(7, 4, '3 7 5 1 10 3 20') == 5
	assert findX(7, 2, '3 7 5 1 10 3 20') == -1
	assert findX(1, 0, '1') == -1
	assert findX(1, 0, '2') == 1
	assert findX(1, 0, '1') == -1
print(findX(n, k, a))


def ans():
	A = input().split()
	B = sorted(list(map(int, input().split())))
	if int(A[1]) == 0 and int(B[0]) != 1:
		print(int(B[0]) - 1)
	elif int(A[1]) == 0 and int(B[0]) == 1:
		print(-1)
	elif len(B) == int(A[1]):
		print(B[-1])
	elif B[int(A[1]) - 1] == B[int(A[1])]:
		print(-1)
	else:
		print(B[int(A[1]) - 1])
ans()


(n, k) = input().split()
n = int(n)
k = int(k)
integers = input().split()
for x in range(n):
	integers[x] = int(integers[x])
integers.sort()
if n == k:
	print(integers[k - 1])
elif k == 0:
	if 1 in integers:
		print(-1)
	else:
		print(1)
elif integers[k - 1] == integers[k]:
	print(-1)
else:
	print(integers[k - 1])


(n, k) = [int(j) for j in input().split()]
a = [int(j) for j in input().split()]
a.sort()
a += [-1]
if k == 0:
	if a[0] > 1:
		print(1)
		exit(0)
	else:
		print(-1)
elif a[k] != a[k - 1]:
	print(a[k - 1])
else:
	print(-1)


(n, x) = [int(i) for i in input().split()]
a = sorted([int(i) for i in input().split()])
count = 0
if x == 0:
	if a[0] != 1:
		print(1)
	else:
		print(-1)
else:
	for i in a:
		if i > a[x - 1]:
			break
		if i <= a[x - 1]:
			count += 1
	if count == x:
		print(a[x - 1])
	else:
		print(-1)


o = input().rstrip().split(' ')
p = input().rstrip().split(' ')
p.sort(key=int)
if int(o[1]) > int(o[0]):
	print(-1)
elif int(o[0]) == int(o[1]):
	print(p[len(p) - 1])
elif int(o[1]) == 0:
	if int(p[0]) > 1:
		print(1)
	else:
		print(-1)
else:
	for i in range(0, len(p) - int(o[1]) + 1):
		f = p[i:i + int(o[1])]
		t = f[len(f) - 1]
		if t != p[int(o[1]) + i]:
			print(t)
			break
		else:
			print(-1)
			break


split = list(map(int, input().split(' ')))
values = list(map(int, input().split(' ')))
values.sort()
if split[1] == 0 and values[split[1]] != 1:
	print(values[split[1]] - 1)
elif split[1] == split[0]:
	print(values[split[0] - 1])
elif values[split[1] - 1] != values[split[1]] and split[1] != 0:
	print(values[split[1] - 1])
else:
	print(-1)


def main():
	(n, k) = map(int, input().split())
	tab = list(map(int, input().split()))
	tab.sort()
	tab.append(10 ** 9 + 1)
	if k == 0:
		if tab[0] - 1 > 0:
			print(tab[0] - 1)
			return
		else:
			print(-1)
			return
	inc = 0
	k -= 1
	if tab[k] != tab[k + 1]:
		print(tab[k])
	else:
		print(-1)
main()


q = input().split()
(n, k) = (int(q[0]), int(q[1]))
a = [int(i) for i in input().split()]
a.sort()
if k == 0:
	if a[0] > 1:
		print(1)
	else:
		print(-1)
elif n == k:
	print(a[-1])
else:
	k -= 1
	if a[k] == a[k + 1]:
		print(-1)
	else:
		print(a[k])


given = input()
integers = input()
given = given.split()
n = int(given[0])
k = int(given[1])
integers = integers.split()
sequence = [int(i) for i in integers]
sequence.sort()
if k == 0:
	if sequence[0] == 1:
		print('-1')
	else:
		print('1')
	exit(0)
if k == n:
	print(sequence[k - 1])
	exit(0)
m = sequence[k - 1]
if k == 1 and n == 1:
	print(m)
	exit(0)
if m == sequence[k]:
	print('-1')
else:
	print(m)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(1)
elif k <= n - 1 and a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k - 1])


(n, k) = map(int, input().split())
s = sorted(list(map(int, input().split())))
if k >= n:
	print(10 ** 9)
elif k == 0:
	if s[0] == 1:
		print(-1)
	else:
		print(1)
elif s[k] - 1 >= s[k - 1]:
	print(s[k] - 1)
else:
	print(-1)


(n, k) = [int(i) for i in input().split()]
numbers = [int(i) for i in input().split()]
numbers.sort()
if k == 0:
	if numbers[0] != 1:
		print('1')
	else:
		print('-1')
elif k == len(numbers):
	print(numbers[k - 1])
elif k > len(numbers):
	print('-1')
elif numbers[k - 1] == numbers[k]:
	print('-1')
else:
	print(numbers[k - 1])


from collections import Counter
(_, k) = map(int, input().split())
n = 0
for (a, c) in sorted(Counter(map(int, input().split())).items()):
	if n == k:
		print(a - 2 + (a > 1))
		break
	if n > k:
		print(-1)
		break
	n += c
else:
	print(-1 if n > k else 1000000000)


def merge(A, B):
	Res = []
	i = 0
	j = 0
	while i < len(A) and j < len(B):
		if A[i] <= B[j]:
			Res.append(A[i])
			i += 1
		else:
			Res.append(B[j])
			j += 1
	Res += A[i:] + B[j:]
	return Res

def MergeSort(A):
	if len(A) <= 1:
		return A
	else:
		L = A[:len(A) // 2]
		R = A[len(A) // 2:]
	return merge(MergeSort(L), MergeSort(R))
(n, k) = input().split()
(n, k) = (int(n), int(k))
a = list(map(int, input().split()))
a = MergeSort(a)
c = True
if k == 0:
	if min(a) > 1:
		print(min(a) - 1)
		c = False
elif n == 1:
	print(a[0])
	c = False
elif n == k:
	print(a[n - 1])
	c = False
elif a[k - 1] < a[k]:
	print(a[k - 1])
	c = False
if c:
	print('-1')


p = input().rstrip().split(' ')
q = input().rstrip().split(' ')
k = int(p[1])
q.sort(key=int)
if k > int(p[0]):
	print(-1)
elif k == int(p[0]):
	print(int(q[len(q) - 1]))
elif k == 0:
	if int(q[0]) == 1:
		print(-1)
	else:
		print(1)
else:
	t = q[0:k]
	if int(q[k]) > int(t[len(t) - 1]):
		print(int(t[len(t) - 1]))
	else:
		print(-1)


(n, k) = map(int, input().split())
m = list(map(int, input().split()))
a = {}
if k != 0:
	for i in range(n):
		if m[i] not in a:
			a[m[i]] = 1
		else:
			a[m[i]] += 1
	a = sorted(a.items(), key=lambda x: x[0])
	for i in range(len(a)):
		k -= a[i][1]
		if k == 0:
			print(a[i][0])
			break
	else:
		print(-1)
elif min(m) == 1:
	print(-1)
else:
	print(1)


d = list(map(int, input().split()))
k = d[1]
lista = list(map(int, input().split()))
lista.sort()
if k == 0:
	if lista[0] == 1:
		print(-1)
	else:
		print(1)
elif len(lista) == 1:
	print(lista[0])
elif d[0] == k:
	print(lista[k - 1])
elif lista[k - 1] == lista[k]:
	print(-1)
else:
	print(lista[k - 1])


(n, k) = map(int, input().split())
list1 = list(map(int, input().split()))
list1.sort()
list1 = [1] + list1
if n == k:
	print(list1[k])
elif list1[k + 1] != list1[k]:
	print(list1[k])
else:
	print(-1)


(n, k) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
a.sort()
ans = -1
if k == 0:
	ans = a[0] - 1
elif k == n:
	ans = a[n - 1]
elif a[k] == a[k - 1]:
	ans = -1
else:
	ans = a[k] - 1
if ans >= 1:
	print(ans)
else:
	print(-1)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
if k == 0:
	x1 = lst[0]
	if x1 > 1:
		print(1)
	else:
		print(-1)
else:
	x1 = lst[k - 1]
	if k - 1 != n - 1:
		x2 = lst[k]
		if x1 == x2:
			print(-1)
		elif x1 + 1 > 10 ** 9:
			print(10 ** 9)
		else:
			print(x1)
	elif lst[k - 1] + 1 > 10 ** 9:
		print(10 ** 9)
	else:
		print(lst[k - 1])


(n, k) = map(int, input().split())
seq = list(sorted(map(int, input().split())))
if k == n or (k != 0 and seq[k] != seq[k - 1]):
	x = seq[k - 1]
elif k == 0 and seq[0] > 1:
	x = 1
else:
	x = -1
print(x)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
if k == 0:
	print(1 if a[0] > 1 else -1)
else:
	print(a[k - 1] if k == n or a[k] > a[k - 1] else -1)


(n, k) = [int(x) for x in input().split()]
lst = [int(x) for x in input().split()]
lst.sort()
if k == 0:
	if lst[0] - 1 > 0:
		print(lst[0] - 1)
	else:
		print(-1)
elif k == n:
	print(lst[k - 1])
elif lst[k - 1] < lst[k] and 0 < lst[k - 1] < 10 ** 9:
	print(lst[k - 1])
else:
	print(-1)


(a, b) = map(int, input().split())
c = [int(s) for s in input().split()]
c = sorted(c)
if b == 0 and c[0] == 1:
	print('-1')
elif b == 0 and c[0] != 1:
	print(str(1))
elif b == a:
	print(str(c[b - 1]))
elif c[b - 1] == c[b]:
	print('-1')
else:
	print(str(c[b - 1]))


(n, k) = [int(a) for a in input().split()]
sequence = [int(a) for a in input().split()]
sequence.sort()
if k == 0 and sequence[0] == 1:
	print(-1)
elif k == 0:
	print(sequence[0] - 1)
elif k == n or sequence[k - 1] != sequence[k]:
	print(sequence[k - 1])
else:
	print(-1)


from bisect import bisect_right, bisect_left
(n, k) = map(int, input().split())
List = [int(x) for x in input().split()]
List.sort()
if k == 0:
	if List[0] == 1:
		print(-1)
	else:
		print(List[0] - 1)
	exit()
if k != n:
	if List[k - 1] == List[k]:
		print(-1)
	else:
		print(List[k - 1])
else:
	print(List[k - 1])


import sys
input = sys.stdin.readline
from collections import Counter
(N, K) = map(int, input().split())
A = sorted(Counter(list(map(int, input().split()))).items(), key=lambda x: x[0])

def main():
	if K == 0:
		out = min([x[0] for x in A]) - 1
		if out >= 1:
			return out
		else:
			return -1
	cnt = 0
	for x in A:
		cnt += x[1]
		if cnt == K:
			return x[0]
		elif cnt > K:
			return -1
	return -1
print(main())


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a = sorted(a)
if k == 0 and n == 1 and (a[0] == 1):
	print(-1)
elif k == n:
	print(max(a))
elif k == 0 and min(a) != 1:
	print(min(a) - 1)
elif k == 0:
	print(-1)
elif a[k - 1] == a[k]:
	print('-1')
else:
	print(a[k - 1])


(n, k) = map(int, input().split())
a = [int(j) for j in input().split()]
a = sorted(a)
ans = 0
if k == 0:
	ans = a[0] - 1
else:
	ans = a[k - 1]
cnt = 0
for i in range(len(a)):
	if a[i] <= ans:
		cnt += 1
if ans < 1 or cnt != k:
	print(-1)
else:
	print(ans)


def read():
	return [int(v) for v in input().split()]

def less_or_equal(a, k):
	b = sorted(a)
	m = b[k - 1]
	if k == 0:
		if 1 < b[0]:
			return 1
		return -1
	if k == len(a):
		return m
	if b[k] == m:
		return -1
	return m

def main():
	(_, k) = read()
	a = read()
	print(less_or_equal(a, k))
main()


(n, k) = map(int, input().split())
L = sorted(list(map(int, input().split())))
if k == n:
	print(L[n - 1])
elif k == 0:
	a = L[0] - 1
	print([a, -1][a == 0])
elif L[k - 1] < L[k]:
	print(L[k - 1])
else:
	print(-1)


from sys import stdin, stdout
import bisect
import math

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

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

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

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

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	(n, k) = mp()
	l = li()
	l.sort()
	c = 0
	if k == 0:
		an = l[0] - 1
	else:
		an = l[k - 1]
	for i in l:
		if i <= an:
			c += 1
	if c != k or an < 1:
		pr(-1)
	else:
		pr(an)
solve()


import math
(n, k) = [int(i) for i in input().split()]
list = sorted([int(i) for i in input().split()])
if k == 0:
	resposta = list[0] - 1
else:
	resposta = list[k - 1]
found = 0
for item in list:
	if item <= resposta:
		found += 1
if resposta < 1 or found != k:
	print('-1')
else:
	print(resposta)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
cnt = 0
if k == 0:
	ans = a[0] - 1
else:
	ans = a[k - 1]
for i in a:
	if i <= ans:
		cnt += 1
if cnt != k or not 10 ** 9 >= ans >= 1:
	print(-1)
else:
	print(ans)


from collections import defaultdict
(x, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.append(10 ** 9 + 1)
if k == 0:
	z = a[0] - 1
	if z <= 0:
		z = -1
elif a[k] != a[k - 1] and a[k - 1] <= 10 ** 9:
	z = a[k - 1]
else:
	z = -1
print(z)


(N, K) = map(int, input().split())
L = list(map(int, input().split()))
L.sort()
if K == 0:
	print('-1' if L[0] == 1 else '1')
elif N == 1 and K == 1:
	print(L[0] if L[0] <= 10 ** 9 and L[0] > 1 else '-1')
elif K == N:
	print(L[-1] if L[-1] <= 10 ** 9 and L[-1] >= 1 else '-1')
else:
	i = K - 1
	if L[i] == L[i + 1]:
		print('-1')
	elif L[i] < L[i + 1] and L[i] <= 10 ** 9:
		print(L[i])
	else:
		print('-1')


inp = list(map(int, input().split(' ')))
n = inp[0]
k = inp[1]
nbrs = list(map(int, input().split(' ')))
nbrs.sort()
res = 0
k -= 1
if k + 1 == n:
	print(nbrs[-1])
elif k + 1 == 0:
	if nbrs[0] - 1 >= 1:
		print(nbrs[0] - 1)
	else:
		print(-1)
elif nbrs[k] == nbrs[k + 1]:
	print(-1)
else:
	nb = nbrs[k]
	print(nb)


(n, k) = map(int, input().split())
arr = map(int, input().split())
arr = sorted(arr)
if n == k:
	print(arr[-1])
elif k == 0:
	if arr[0] == 1:
		print(-1)
	else:
		print(1)
elif arr[k - 1] == arr[k]:
	print(-1)
else:
	print(arr[k - 1])


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
limit = -1
if k != 0:
	limit = l[k - 1]
	if k != n and l[k] == limit:
		limit = -1
elif l[0] > 1:
	limit = 1
print(limit)


[n, k] = input().split(' ')
n = eval(n)
k = eval(k)
arr = input().split(' ')
for i in range(n):
	arr[i] = eval(arr[i])
if k == 0:
	ans = 1
	for i in range(n):
		if arr[i] == 1:
			ans = -1
	print(ans)
elif k == n:
	print(1000000000)
else:
	arr.sort()
	if arr[k] == arr[k - 1]:
		print(-1)
	else:
		print(arr[k - 1])


def solve():
	(n, k) = input().split()
	k = int(k)
	lst = list(map(int, input().split()))
	lst = sorted(lst)
	ans = 0
	if k == 0:
		ans = lst[0] - 1
	else:
		ans = lst[k - 1]
	counter = 0
	for i in range(len(lst)):
		if lst[i] <= ans:
			counter += 1
	if counter != k or not (1 <= ans and ans <= 1000 * 1000 * 1000):
		print('-1')
		return 0
	print(ans)
solve()


def main():
	inpt = list(map(int, input().split()))
	n = inpt[0]
	k = inpt[1]
	arr = sorted(list(map(int, input().split())))
	if k == n:
		print(arr[k - 1])
	elif k == 0:
		print(1 if arr[0] > 1 else -1)
	elif arr[k - 1] == arr[k]:
		print(-1)
	else:
		print(arr[k - 1])
main()


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


def main():
	(n, k) = map(int, input().split())
	line = [int(i) for i in input().split()]
	line.sort()
	if k == 0:
		if line[0] == 1:
			print(-1)
		else:
			print(1)
	else:
		right = line[k - 1]
		if k < n and line[k] == right:
			print(-1)
		else:
			print(right)
main()


l1 = list(map(int, input().split()))
n = l1[0]
k = l1[1]
l = list(map(int, input().split()))
l.sort()
ans = l[k - 1]
l.reverse()
if k == 0:
	if l[-1] == 1:
		print(-1)
	else:
		print(l[-1] - 1)
elif n - l.index(ans) <= k:
	print(ans)
else:
	print(-1)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
(x, c) = (0, 0)
f = 0
if k == 0:
	if l[0] == 1:
		print(-1)
	else:
		print(1)
elif k < n and l[k - 1] < l[k]:
	print(l[k - 1])
elif k == n:
	print(l[-1])
else:
	print(-1)


(total, pular) = [int(z) for z in input().split()]
array = [int(z) for z in input().split()]
array.sort()
res = 0
if pular - 1 == -1:
	res = array[0] - 1
elif pular >= total:
	res = array[len(array) - 1]
elif array[pular - 1] == array[pular]:
	res = -1
else:
	res = array[pular - 1]
if res > 1000000000:
	print(-1)
elif res < 1:
	print(-1)
else:
	print(res)


import sys
from collections import Counter, defaultdict as ddict
from pprint import pprint
from functools import lru_cache
from heapq import *
from itertools import zip_longest
from string import *
cache = lru_cache(None)
rl = lambda : next(sys.stdin, '').rstrip('\n')
ri = lambda : int(rl())
rfs = lambda : rl().split()
ris = lambda : list(map(int, rfs()))
rds = lambda : list(map(float, rfs()))
(n, k) = ris()
a = ris()
a.sort()
ans = -1
if k == n:
	if n == 0:
		ans = 1
	else:
		ans = a[-1]
elif k == 0:
	if a[0] > 1:
		ans = 1
elif k < n and a[k] != a[k - 1]:
	if a[k - 1] + 1 == a[k]:
		ans = a[k - 1]
	else:
		ans = a[k - 1] + 1
print(ans)


def fun():
	(a, b) = map(int, input().split())
	c = [int(i) for i in input().split()]
	c.sort()
	x = 0
	for i in range(b):
		x = c[i]
	if x == 0:
		if c[0] == 1:
			return -1
		else:
			return 1
	if a > b:
		if x == c[b]:
			return -1
		else:
			return x
	else:
		return x
print(fun())


def read_nums():
	return [int(x) for x in input().split()]

def main():
	(n, k) = read_nums()
	nums = sorted(read_nums())
	if k == 0:
		if nums[0] == 1:
			print(-1)
		else:
			print(1)
		return
	if k - 1 < len(nums):
		if k < len(nums) and nums[k] == nums[k - 1]:
			print(-1)
		else:
			print(nums[k - 1])
	else:
		print(-1)
main()


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
if k is 0:
	if a[0] is 1:
		print(-1)
	else:
		print(a[0] - 1)
	exit()
c = 0
for x in a:
	if x <= a[k - 1]:
		c = c + 1
if c == k:
	print(a[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split(' '))
arr = sorted(list(map(int, input().split(' '))))
if k == 0:
	print(-1 if arr[0] == 1 else 1)
else:
	i = 0
	while i < k:
		if i < n - 1 and arr[i] == arr[i + 1]:
			while i < n - 1 and arr[i] == arr[i + 1]:
				i += 1
		i += 1
	print(arr[i - 1] if i == k else -1)


(n, k) = map(int, input().strip().split(' '))
ar = list(map(int, input().strip().split(' ')))
ar.sort()
if k != 0:
	p = ar[k - 1]
if n != k:
	p1 = ar[k]
if n == k:
	if p <= 1000000000:
		print('1000000000')
	else:
		print(-1)
elif k == 0:
	if ar[0] > 1:
		print(1)
	else:
		print('-1')
elif p1 >= p + 1:
	print(p)
else:
	print('-1')


import sys
input = sys.stdin.readline
import collections as cc
import bisect as bi
I = lambda : list(map(int, input().split()))
(n, k) = I()
l = [1] + sorted(I())
if n == k or l[k] != l[k + 1]:
	print(l[k])
else:
	print(-1)


(n, k) = (int(i) for i in input().split())
a = sorted([int(i) for i in input().split()])
if k == 0:
	ans = 1
else:
	ans = a[k - 1]
for i in range(k, n):
	if a[i] <= ans:
		ans = -1
		break
print(ans)


(n, k) = map(int, input().split())
p = [*map(int, input().split())]
p.sort()
cnt = p[0:k]
if k == 0:
	print(p[0] - 1 if p[0] != 1 else -1)
elif k < n and p[k - 1] == p[k]:
	print(-1)
else:
	print(p[k - 1])


from sys import stdin, stdout

def main():
	(n, k) = [int(i) for i in stdin.readline().split()]
	a = [int(i) for i in stdin.readline().split()]
	a.sort()
	if k == 0:
		x = a[0] - 1
		if x == 0:
			x = -1
	else:
		x = a[k - 1]
		if k != n:
			if x == a[k]:
				x = -1
	stdout.write(str(x) + '\n')
main()


(a, b) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
if b == 0 and arr[0] > 1:
	print(arr[0] - 1)
elif a == 1 and b == 1:
	print(arr[0])
elif a == b:
	print(arr[-1])
elif arr[b] == arr[b - 1] or b == 0:
	print('-1')
else:
	print(arr[b - 1])


import sys
read = lambda : map(int, sys.stdin.buffer.readline().split())
(n, k) = read()
a = list(read())
a.sort()
if k == 0:
	print(a[0] - 1 if a[0] > 1 else -1)
else:
	for i in range(n):
		if i < n - 1 and a[i] == a[i + 1]:
			continue
		if i == k - 1:
			print(a[i])
			break
	else:
		print(-1)


from sys import stdin as cin
nk = [int(x) for x in cin.readline().split()]
arr = [int(x) for x in cin.readline().split()]
sol = -1
arr.sort()
if nk[1] == 0:
	print(arr[0] - 1 if arr[0] > 1 else -1)
elif nk[1] == nk[0]:
	print(arr[-1])
elif arr[nk[1] - 1] != arr[nk[1]]:
	print(arr[nk[1] - 1])
else:
	print(-1)


def is_possible(num, k):
	global array
	counter = 0
	for i in range(len(array)):
		if array[i] <= num:
			counter += 1
	return counter >= k
(amount, k) = [int(s) for s in input().split()]
array = [int(s) for s in input().split()]
array = sorted(array)
left = 0
right = int(10000000000.0)
while right - left > 1:
	middle = (right + left) // 2
	if is_possible(middle, k):
		right = middle
	else:
		left = middle
count = 0
for i in range(len(array)):
	if array[i] <= right:
		count += 1
if count != k:
	print(-1)
else:
	print(right)


(l, n) = map(int, input().split())
arr = [int(x) for x in input().split()]
arr.sort()
if n == 0:
	ans = arr[0] - 1
elif n < l and arr[n - 1] == arr[n]:
	ans = -1
else:
	ans = arr[n - 1]
if ans == -1 or ans < 1 or ans > 1000000000:
	print(-1)
else:
	print(ans)


from heapq import heappush, heappop
(n, k) = map(int, input().split())
a = []
b = {}
c = input().split()
m = 10 ** 9
for i in c:
	i = int(i)
	if i < m:
		m = i
	if i in b:
		b[i] += 1
	else:
		heappush(a, i)
		b[i] = 1
c = 0
v = m - 1
while c < k and n:
	v = heappop(a)
	c += b[v]
	n -= b[v]
if c == k and v >= 1:
	print(v)
else:
	print(-1)


(n, k) = map(int, input().split())
myList = [int(i) for i in input().split()]
myList.sort()

def goodAnswer(answer):
	if 1 <= answer <= 10 ** 9:
		return answer
	return -1

def f(myList):
	answer = -1
	if k == 0:
		if myList:
			answer = min(myList) - 1
		return goodAnswer(answer)
	if k == n:
		answer = max(myList)
		return goodAnswer(answer)
	if myList[k - 1] != myList[k]:
		answer = myList[k - 1]
	return goodAnswer(answer)
print(f(myList))


import math
import sys
import itertools
import itertools
import collections

def sa(Type=int):
	return [Type(x) for x in input().split()]

def solve(t):
	(n, k) = sa()
	arr = sa()
	if k == 0:
		mn = min(arr)
		print(-1 if mn == 1 else mn - 1)
		return
	arr.sort()
	cc = 0
	lastVal = 0
	lastIdx = 0
	for (i, a) in enumerate(arr):
		cc += 1
		lastVal = a
		lastIdx = i
		if cc == k:
			break
	if lastIdx < n - 1 and arr[lastIdx + 1] == lastVal:
		print(-1)
	else:
		print(lastVal)
solve(1)


(n, k) = map(int, input().split())
numbers = sorted(list(map(int, input().split())))
if k == 0:
	if numbers[0] > 1:
		print(numbers[0] - 1)
	else:
		print(-1)
elif k == n or numbers[k - 1] != numbers[k]:
	print(numbers[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
seq = list(map(int, input().split()))
seq = sorted(seq)
res = -1
if k == 0:
	res = seq[0] - 1
	if res < 1:
		res = -1
elif k == n:
	res = seq[-1]
else:
	at_k = seq[k - 1]
	at_k1 = seq[k]
	if at_k == at_k1:
		res = -1
	else:
		res = at_k
print(res)


(n, k) = map(int, input().split(' '))
l = sorted(list(map(int, input().split(' '))))
a = []

def p(i):
	print(i)
	exit()
if k == 0:
	if l[0] > 1:
		p(l[0] - 1)
	else:
		p(-1)
elif k == n:
	p(l[k - 1])
elif l[k] == l[k - 1]:
	p(-1)
else:
	p(l[k - 1])


(n, k) = map(int, input().split())
numbers = list(map(int, input().split()))
numbers.sort()
k -= 1
resalt = numbers[k]
if k == n - 1:
	print(numbers[k])
elif k == -1 and numbers[0] > 1:
	print('1')
elif k == -1 and numbers[0] < 2:
	print('-1')
elif k > -1 and numbers[k + 1] == resalt:
	print('-1')
elif resalt > 1000000000:
	print('-1')
else:
	print(resalt)


def init():
	(n, k) = map(lambda x: int(x), input().split(' '))
	sequence = list(map(lambda x: int(x), input().split(' ')))
	sequence.sort()
	if n == k:
		print(sequence[k - 1])
		return
	if k == 0:
		if sequence[0] > 1:
			print(1)
			return
		else:
			print(-1)
			return
	if sequence[k - 1] < sequence[k]:
		print(sequence[k - 1])
	else:
		print(-1)
	return
init()


import bisect
(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
ans = -1
if k != 0:
	for i in a:
		pos = bisect.bisect_right(a, i)
		if pos == k:
			ans = i
			break
elif a[0] != 1:
	ans = a[0] - 1
print(ans)


(n, k) = input().split(' ')
k = int(k)
n = int(n)
vet = []
vet = input().split(' ')
tam = len(vet)
for i in range(tam):
	vet[i] = int(vet[i])
vet.sort()
if k == 0:
	if vet[0] != 1:
		print(1)
	else:
		print(-1)
elif n == k:
	print(vet[k - 1])
elif n > k:
	k = k - 1
	ultimo = vet[k]
	if ultimo == vet[k + 1]:
		print(-1)
	else:
		final = ultimo
		print(final)
else:
	print(-1)


(a, k) = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
h.sort()
if k == 0:
	ans = h[k] - 1
else:
	ans = h[k - 1]
cnt = 0
for i in h:
	if i <= ans:
		cnt += 1
if ans < 1 or cnt != k:
	print(-1)
else:
	print(ans)


(n, k) = [int(x) for x in input().split(' ')]
nums = [int(x) for x in input().split(' ')]
nums.sort()
num = nums[k - 1]
if k == 1 and n >= 2:
	if nums[1] - nums[0] == 0:
		print(-1)
	else:
		print(nums[0])
elif k == n:
	print(num)
elif k == 0:
	if nums[0] - 1 < 1:
		print(-1)
	else:
		print(nums[0] - 1)
elif nums[k] != num:
	print(num)
else:
	print(-1)


import math

def fact(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
	return ans

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
(n, k) = map(int, input().split())
arr = sorted(list(map(int, input().split())))
if k == 0:
	if min(arr) <= 1:
		print(-1)
	else:
		print(min(arr) - 1)
else:
	cnt = 0
	pnt = 0
	while cnt < k:
		mark = int(pnt)
		while arr[mark] == arr[pnt]:
			cnt += 1
			pnt += 1
			if pnt == len(arr):
				break
	if cnt == k:
		print(arr[pnt - 1])
	else:
		print(-1)


(n, k) = list(map(int, input().strip().split()))
nums = list(map(int, input().strip().split()))
nums = sorted(nums)
if k == 0:
	if nums[0] > 1:
		print(1)
	else:
		print(-1)
elif k == n:
	if nums[k - 1] <= 1000000000.0:
		print(nums[k - 1])
	else:
		print(-1)
elif nums[k - 1] == nums[k]:
	print(-1)
else:
	print(nums[k - 1])


(n, k) = map(int, input().split())
A = sorted([int(x) for x in input().split()])
if k == 0:
	if A[0] - 1:
		print(A[0] - 1)
	else:
		print(-1)
elif k == n or A[k] != A[k - 1]:
	print(A[k - 1])
else:
	print(-1)


(n, k) = input().split()
(n, k) = [int(n), int(k)]
a = [int(i) for i in input().split()]
a.sort()
number = a[k - 1]
flag = 0
if k < n:
	if a[k] == a[k - 1]:
		flag = 1
if k == 0:
	if a[0] != 1:
		print('1')
	else:
		print('-1')
elif flag == 0:
	print(number)
else:
	print('-1')


(n, k) = map(int, input().split())
l = sorted([int(i) for i in input().split()])
if k is 0:
	if 1 not in l:
		print(1)
		exit()
	else:
		print(-1)
		exit()
try:
	if l[k - 1] == l[k]:
		print(-1)
	else:
		print(l[k - 1])
except:
	print(l[k - 1])


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	k = inlt()[1]
	lst = inlt()
	lst.sort()
	if k == len(lst):
		print(1000000000)
		return
	if lst[k] > get(lst, k - 1, 1):
		print(lst[k] - 1)
	else:
		print(-1)

def get(lst, idx, default):
	if idx == -1:
		return default
	return lst[idx]
BUFSIZE = 8192

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())

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, k) = map(int, input().split())
z = list(map(int, input().split()))
z.sort()
if k == 0:
	if z[0] == 1:
		print(-1)
	else:
		print(1)
	exit()
if k >= len(z):
	print(max(z))
	exit()
elif z[k] == z[k - 1]:
	print(-1)
else:
	print(z[k - 1])


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
l = 0
r = int(1000000000.0)
while r - l > 1:
	m = (r + l) // 2
	l1 = -1
	r1 = len(a)
	while r1 - l1 > 1:
		m1 = (r1 + l1) // 2
		if a[m1] <= m:
			l1 = m1
		else:
			r1 = m1
	if l1 + 1 < k:
		l = m
	else:
		r = m
m = r
l1 = -1
r1 = len(a)
while r1 - l1 > 1:
	m1 = (r1 + l1) // 2
	if a[m1] <= m:
		l1 = m1
	else:
		r1 = m1
if l1 + 1 == k:
	print(m)
else:
	print(-1)


(n, k) = [int(e) for e in input().split(' ')]
L = [int(e) for e in input().split(' ')]
L.sort()
if k == 0 and L[0] > 1:
	print(1)
	exit()
if k > n or k == 0:
	print(-1)
elif k == n:
	print(L[k - 1])
elif L[k - 1] != L[k]:
	print(L[k - 1])
else:
	print(-1)


k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
if k[1] == 0:
	if a[0] == 1:
		print(-1)
		exit()
	else:
		print(1)
		exit()
x = a[k[1] - 1]
if len(a) == k[1]:
	print(a[len(a) - 1])
elif a[k[1]] == x:
	print(-1)
else:
	print(x)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
if k == 0:
	if arr[0] - 1 > 0:
		print(arr[0] - 1)
	else:
		print(-1)
elif arr.count(arr[k - 1]) == 1 or arr[::-1].index(arr[k - 1]) == n - k:
	print(arr[k - 1])
else:
	print(-1)


def main():
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	if k == 0:
		print(1 if a[0] != 1 else -1)
		exit()
	x = a[:k][-1]
	print(x if a[k - 1:].count(x) == 1 else -1)
main()


(n, k) = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]
array.sort()
if k == 0:
	if array[0] > 1:
		print(1)
	else:
		print(-1)
elif k != n and array[k - 1] == array[k]:
	print(-1)
else:
	print(array[k - 1])


(n, k) = input().split()
n = int(n)
k = int(k)
a = input().split()
a = [int(i) for i in a]
a.sort()
if k == 0:
	if a[0] <= 1:
		print(-1)
	else:
		print(1)
elif k < n:
	a_k = a[k - 1]
	if a[k] == a_k:
		print(-1)
	elif a[k] > a_k:
		print(a_k)
else:
	print(10 ** 9)


def bubbleSort(arr):
	n = len(arr)
	for i in range(n):
		for j in range(0, n - i - 1):
			if arr[j] > arr[j + 1]:
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
maxi = 0
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
if k == 0 and a[0] > 1:
	print('1')
elif k == 0 and a[0] == 1:
	print('-1')
elif k <= n - 1:
	if a[k - 1] != a[k]:
		print(a[k - 1])
	else:
		print('-1')
elif k == n:
	print(a[k - 1])


from collections import Counter
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
if k == 0:
	if min(a) == 1:
		print(-1)
	else:
		print(min(a) - 1)
	exit()
C = Counter(a)
ans = 0
for (k_, v_) in sorted(C.items(), key=lambda x: x[0]):
	ans += v_
	if ans == k:
		print(k_)
		exit()
	elif ans > k:
		print(-1)
		exit()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
if n == k:
	print(max(a))
	exit()
if k == 0:
	if min(a) == 1:
		print(-1)
	else:
		print(min(a) - 1)
	exit()
a.sort()
if a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k] - 1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a = [1] + a + [10 ** 9 + 1]
if a[k] == a[k + 1]:
	print(-1)
else:
	print(a[k])


import logging
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.addHandler(ch)

def solve(k, sequence):
	if k == 0:
		value = min(sequence) - 1
		return value if 1 <= value <= 10 ** 9 else -1
	sequence = sorted(sequence)
	v = sequence[k - 1]
	if len([x for x in sequence if x <= v]) != k:
		return -1
	return v

def main():
	(_, k) = map(int, input().strip().split())
	sequence = [int(x) for x in input().strip().split()]
	result = solve(k, sequence)
	print(result)
main()


import os
import sys
(n, k) = [int(i) for i in input().split()]
s = input().split()
s = [int(i) for i in s]
s.sort()
if k == 0:
	if s[0] - 1 >= 1:
		print(s[0] - 1)
	else:
		print(-1)
elif k == n:
	print(s[k - 1])
elif s[k] - s[k - 1] >= 1:
	print(s[k - 1])
else:
	print(-1)


rd = lambda : map(int, input().split())
(n, k) = rd()
a = [1] + sorted(rd())
print(a[k] if k == n or a[k + 1] - a[k] else -1)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l = sorted(l)
if k == 0:
	if 1 in l:
		print(-1)
	else:
		print(1)
else:
	candidate = l[k - 1]
	cont = 0
	for i in l:
		if i <= candidate:
			cont += 1
	if cont == k:
		print(candidate)
	else:
		print(-1)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
ans = -1
if k == 0:
	ans = arr[0] - 1
else:
	ans = arr[k - 1]
cnt = 0
for i in range(n):
	if arr[i] <= ans:
		cnt += 1
if cnt != k or (ans < 1 or ans > 1000 * 1000 * 1000):
	ans = -1
print(ans)


def main():
	(n, k) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	l.sort()
	if k == 0:
		if l[0] != 1:
			print(l[0] - 1)
		else:
			print(-1)
	elif n == 1 and k == 1:
		print(l[0])
	elif n == k:
		print(l[k - 1])
	elif l[k] > l[k - 1]:
		print(l[k - 1])
	else:
		print(-1)
main()


line1 = input().split()
n = int(line1[0])
k = int(line1[1])
line2 = input().split()
seq = []
for i in range(n):
	seq.append(int(line2[i]))
seq.sort()
sub = seq[:k]
counter = 0
number = -1
if seq[0] > 1:
	number = seq[0] - 1
if len(sub) != 0:
	number = int(sub[len(sub) - 1])
for i in range(n):
	a = seq[i]
	if a <= number:
		counter += 1
if counter != len(sub):
	print(-1)
elif number < 10 ** 9:
	print(number)
else:
	print(10 ** 9)


(n, k) = map(int, input().split(' '))
numbers = list(map(int, input().split(' ')))
numbers.sort()
k = k - 1
if k < 0:
	if numbers[0] > 1:
		print(1)
	else:
		print(-1)
elif len(numbers) > k + 1 and numbers[k] == numbers[k + 1]:
	print(-1)
else:
	print(numbers[k])


(a, b) = map(int, input().split())
z = sorted(map(int, input().split()))
if b > 0:
	if a == b:
		print(z[-1])
	elif z[b] == z[b - 1]:
		print(-1)
	else:
		print(z[b - 1])
elif z[0] > 1:
	print(z[0] - 1)
else:
	print(-1)


def solve():
	(n, k) = mul()
	l = seq()
	l.sort()
	if k == n:
		print(10 ** 9)
	elif k == 0:
		if l[0] - 1 >= 1:
			print(1)
		else:
			print(-1)
	else:
		val = l[k]
		if val - 1 >= l[k - 1]:
			print(val - 1)
		else:
			print(-1)
import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
solve()


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
if k == 0:
	if lst[0] > 1:
		print(1)
	else:
		print(-1)
else:
	j = lst[k - 1]
	if k != n and lst[k] == j:
		print(-1)
	else:
		print(j)


from collections import Counter

def readline():
	return tuple(map(int, input().split()))

def solve():
	(n, k) = readline()
	seq = Counter(readline())
	if not k:
		return -1 if seq[1] else 1
	for (a, count) in sorted(seq.items()):
		if k > count:
			k -= count
		elif k == count:
			return a
		else:
			return -1
	return -1
print(solve())


(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
check = {}
min_a = 1000000001
for i in arr:
	if i not in check:
		check[i] = 1
	else:
		check[i] += 1
	if i < min_a:
		min_a = i
total = 0
if k == 0 and min_a >= 2:
	print(min_a - 1)
	exit()
for i in sorted(check.keys()):
	total += check[i]
	if total == k:
		print(i)
		exit()
	elif total > k:
		print(-1)
		exit()


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
if k == 0:
	if min(a) == 1:
		print(-1)
	else:
		print(1)
	exit()
c = a[k - 1] + 1
counter = 0
for el in a:
	if el <= c:
		counter += 1
if counter == k and c <= 10 ** 9:
	print(c)
	exit()
c = a[k - 1]
counter = 0
for el in a:
	if el <= c:
		counter += 1
if counter == k and c <= 10 ** 9:
	print(c)
	exit()
print(-1)


(n, k) = map(int, input().split())
num = sorted([int(x) for x in input().split()])
if k == 0:
	num[k] -= 1
	if num[k]:
		print(num[k])
	else:
		print(-1)
	exit()
new = {}
if k == 0:
	print(1)
	exit()
for i in range(n):
	if num[i] in new.keys():
		new[num[i]] += 1
	else:
		new[num[i]] = 1
total = 0
for i in new.keys():
	total += new[i]
	if total == k:
		print(i)
		break
else:
	print(-1)


(n, k) = input().split(' ')
n = int(n)
k = int(k)
b = []
s = input().split(' ')
s = [int(item) for item in s]
s = sorted(s)
if (k == 0) & (s[0] > 1):
	print(s[0] - 1)
elif (k == 0) & (s[0] == 1):
	print(-1)
elif n == k:
	print(s[k - 1])
elif s[k - 1] == s[k]:
	print(-1)
else:
	print(s[k - 1])


from collections import Counter, defaultdict
BS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def to_base(s, b):
	res = ''
	while s:
		res += BS[s % b]
		s //= b
	return res[::-1] or '0'
alpha = 'abcdefghijklmnopqrstuvwxyz'
from math import floor, ceil, pi
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919]

def primef(n, plst=[]):
	if n == 1:
		return plst
	else:
		for m in primes:
			if n % m == 0:
				return primef(n // m, plst + [m])
		return primef(1, plst + [n])

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

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

def countOverlapping(string, sub):
	count = start = 0
	while True:
		start = string.find(sub, start) + 1
		if start > 0:
			count += 1
		else:
			return count
(n, k) = lmii()
nums = lmii()
nums.sort()
if k == 0:
	print(-1 if nums[0] == 1 else nums[0] - 1)
elif k < n and nums[k - 1] != nums[k]:
	print(nums[k - 1])
elif k == n:
	print(nums[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
L = sorted([int(i) for i in input().split()])
if k != n and k != 0:
	if L[k - 1] != L[k]:
		print(L[k - 1])
	else:
		print(-1)
elif k == n:
	print(1000000000)
elif k == 0:
	if L[0] == 1:
		print(-1)
	else:
		print(1)
else:
	print(-1)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
if k == n:
	print(lst[-1])
elif k == 0:
	t = lst[0] - 1
	print(-1 if t < 1 else t)
elif lst[k - 1] == lst[k]:
	print(-1)
else:
	print(lst[k - 1])


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a = sorted(a)
count = 0
if n < k:
	print(-1)
	exit()
if k == 0:
	ans = a[0] - 1
else:
	ans = a[k - 1]
for i in range(n):
	if a[i] <= ans:
		count += 1
if count != k or ans < 1:
	print(-1)
else:
	print(ans)


I = lambda : map(int, input().split())
(n, k) = I()
a = sorted(list(I()))
if k == 0:
	print(-1 if a[0] == 1 else a[0] - 1)
	exit()
try:
	print(a[k - 1] if a[k - 1] != a[k] else -1)
except:
	print(a[k - 1])


(n, k) = map(int, input().split(' '))
numbers = list(map(int, input().split(' ')))
num = sorted(numbers)
if k == 0:
	if num[0] >= 2:
		print(1)
	else:
		print(-1)
elif k == n:
	print(num[-1])
elif num[k - 1] < num[k]:
	print(num[k - 1])
else:
	print(-1)


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
ans = a[k - 1]
if k == 0:
	ans = a[0] - 1
	if ans != 0:
		print(ans)
	else:
		print(-1)
elif k != len(a):
	if a[k] == ans:
		print(-1)
	else:
		print(ans)
else:
	print(ans)


import collections

class Solution:

	def solve(self, n, k, arr):
		arr.sort()
		if k == 0:
			ans = arr[0] - 1
		else:
			ans = arr[k - 1]
		count = 0
		for i in range(n):
			if arr[i] <= ans:
				count += 1
		if count != k or ans < 1 or ans > 10 ** 9:
			return -1
		return ans
sol = Solution()
[n, k] = list(map(int, input().strip().split()))
arr = list(map(int, input().strip().split()))
print(sol.solve(n, k, arr))


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
cnt = 0
groupcnt = 0
prev = 0
ans = -1
if K == 0:
	if 1 < A[0]:
		ans = 1
else:
	for a in A:
		if a == prev:
			groupcnt += 1
		else:
			cnt += groupcnt
			if cnt == K:
				ans = prev
			groupcnt = 1
		prev = a
	if ans == -1 and 0 < groupcnt:
		cnt += groupcnt
		if cnt == K:
			ans = prev
		groupcnt = 0
print(ans)


from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
ls = sorted(list(map(int, stdin.readline().split())))
edge = ls[k - 1]
ans = ''
if k == 0:
	if ls[0] == 1:
		ans = '-1'
	else:
		ans = '1'
elif k != n and k != 0:
	if edge == ls[k]:
		ans = '-1'
	else:
		ans = f'{edge}'
elif k == n:
	ans = f'{ls[-1]}'
stdout.write(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
c = 0
if k == 0:
	if a[0] - 1 >= 1 and a[0] - 1 <= pow(10, 9):
		print(a[0] - 1)
	else:
		print(-1)
else:
	for i in a:
		if i <= a[k - 1]:
			c += 1
	if c == k:
		print(a[k - 1])
	else:
		print(-1)


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1
(n, k) = map(int, z().split())
l = [1] + sorted(list(map(int, z().split())))
ans = l[k]
print(l[k] if k == n or l[k + 1] - l[k] else -1)


(n, k) = [int(i) for i in input().split()]
m = sorted([int(i) for i in input().split()])
if len(m) == k:
	print(m[k - 1])
elif k == 0:
	if m[0] - 1 > 0:
		print(m[0] - 1)
	else:
		print(-1)
elif m[k - 1] != m[k]:
	print(m[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
a = [int(s) for s in input().split()]
a.sort()
if k == 0:
	print(-1 if a[0] - 1 < 1 else a[0] - 1)
else:
	print(a[k - 1] if k == len(a) or a[k] != a[k - 1] else -1)


import sys
input = sys.stdin.readline
from math import ceil, floor

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
(n, k) = int_array()
a = sorted(int_array())
f = 1
kth = a[k - 1]
if k == 0:
	if a[0] - 1 >= 1:
		print(a[0] - 1)
	else:
		print(-1)
else:
	if k < n and a[k] == kth:
		f = 0
	if f:
		print(kth)
	else:
		print(-1)


lenghts = input()
lenghts = lenghts.split(' ')
n = int(lenghts[0])
k = int(lenghts[1])
arr = input()
if k == n:
	print(int(1000000000.0))
else:
	arr = arr.split(' ')
	intarr = [int(x) for x in arr]
	intarr.sort()
	if k == 0:
		if intarr[0] > 1:
			print(1)
		else:
			print(-1)
	else:
		infquota = intarr[k - 1]
		sup = intarr[k]
		if sup == infquota:
			print(-1)
		else:
			if infquota + 1 < sup:
				infquota += 1
			if 1 <= infquota <= int(1000000000.0):
				print(infquota)
			else:
				print(-1)


def leq(a, x):
	return sum((y <= x for y in a))
(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
if k == 0:
	ans = a[0] - 1
else:
	ans = a[k - 1]
if ans <= 0 or leq(a, ans) != k:
	print(-1)
else:
	print(ans)


def check(n, k, j):
	list1 = []
	for x in j:
		list1.append(int(x))
	list1.sort()
	if n == 1 and k == 0:
		b = list1[0]
		if b == 1 or b == 0:
			return '-1'
		else:
			return b - 1
	elif n == 1 and k == 1:
		b = list1[0]
		return b
	elif n == k:
		return list1[-1]
	elif k == 0:
		b = list1[0]
		if b == 1:
			return '-1'
		else:
			return b - 1
	else:
		a = list1[k - 1]
		if a == list1[k]:
			return -1
		else:
			return a
i = input().split()
n = int(i[0])
k = int(i[1])
j = input().split()
print(check(n, k, j))


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

def find(a, b):
	t = 0
	for i in a:
		if i <= b:
			t += 1
		else:
			return t
	return t

def binary(a, s, e):
	if find(a, s) == k:
		return s
	if find(a, e) == k:
		return e
	if s == e or s + 1 == e:
		if find(a, s) == k:
			return s
		if find(a, e) == k:
			return k
		else:
			return -1
	if find(a, (s + e) // 2) > k:
		return binary(a, s, (s + e) // 2)
	else:
		return binary(a, (s + e) // 2, e)
print(binary(a, 1, 1000000000))


def solve(n, k, arr):
	order = []
	count = {}
	arr.sort()
	if k == 0 and arr[0] > 1:
		return 1
	elif k == 0 and arr[0] == 1:
		return -1
	for i in arr:
		if i in count:
			count[i] += 1
		else:
			order.append(i)
			count[i] = 1
	lim = 0
	for i in order:
		if lim + count[i] > k:
			return -1
		elif lim + count[i] == k:
			return i
		lim += count[i]
(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
print(solve(n, k, arr))


(n, k) = map(int, input().split())
l = [int(x) for x in input().split()]
l.sort()
if k == 0 and l[0] == 1:
	ans = -1
elif k == 0:
	ans = l[0] - 1
elif k == n:
	ans = l[n - 1]
elif l[k] > l[k - 1]:
	ans = l[k] - 1
elif l[k] == l[k - 1]:
	ans = -1
print(ans)


from collections import Counter
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
x = Counter(l)
l = list(set(l))
l.sort()
el = 0
ans = 0
for t in l:
	if el >= k:
		break
	el += x[t]
	ans = t
if k == 0:
	ans = min(l) - 1
if el == k:
	print(ans if ans != 0 else -1)
else:
	print(-1)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
try:
	if k == 0 and a[0] > 1:
		print(a[0] - 1)
	elif a[k] - 1 >= a[k - 1]:
		print(a[k] - 1)
	else:
		print(-1)
except IndexError:
	print(a[n - 1])


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())
(n, k) = rint()
a = list(rint())
a.sort()
if k == n:
	print(a[-1])
elif k == 1:
	if a[k - 1] == a[k]:
		print(-1)
	else:
		print(a[k - 1])
elif k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(1)
elif a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k - 1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
min = a[0]
max = a[n - 1]
if k == 0:
	if min > 1:
		print(min - 1)
	else:
		print(-1)
elif k == n:
	print(max)
else:
	num = a[k - 1]
	if num < a[k]:
		print(num)
	else:
		print('-1')


(n, k) = map(int, input().split(' '))
seq = list(map(int, input().split(' ')))
seq.sort()
if n == 1:
	if k == 0:
		if seq[k] == 1:
			ans = -1
		else:
			ans = 1
	elif k == 1:
		ans = seq[0]
elif k == 0:
	if 1 in seq:
		ans = -1
	else:
		ans = 1
elif k == n:
	ans = max(seq)
elif seq[k - 1] == seq[k]:
	ans = -1
else:
	ans = seq[k - 1]
print(ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
if k == 0:
	ans = arr[0] - 1
else:
	ans = arr[k - 1]
count = 0
for i in arr:
	if i <= ans:
		count += 1
if count != k or not (ans <= 1000000000 and ans >= 1):
	print('-1')
else:
	print(ans)


(n, k) = map(int, input().split())
a = [-1]
a += list(map(int, input().split()))
a.sort()
a.append(-1)
if k == 0 and a[1] > 1:
	print('1')
elif a[k] == a[k + 1]:
	print('-1')
else:
	print(str(int(a[k])))


(n, k) = (int(x) for x in input().split())
s = list(map(int, input().split()))
ss = sorted(s)
if k == 0:
	print(-1 if ss[0] == 1 else 1)
	exit()
if k == n:
	print(ss[-1])
	exit()
if ss[k - 1] != ss[k]:
	print(ss[k - 1])
else:
	print(-1)


mod = 10 ** 9 + 7
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, k) = f()
l = sorted(il())
if k == 0:
	print(l[k] - 1 if l[k] - 1 > 0 else -1)
elif k == n:
	print(l[k - 1])
else:
	print(l[k - 1] if l[k - 1] != l[k] else -1)


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
L = sorted(L)
L.append(-1)
if k == 0 and L[0] >= 2:
	print(1)
elif L[k] != L[k - 1]:
	print(L[k - 1])
else:
	print('-1')


(n, k) = map(int, input().split())
ar = sorted([int(x) for x in input().split()])
if k == 0:
	print(-1 if ar[0] == 1 else 1)
elif k < n and ar[k - 1] == ar[k]:
	print(-1)
else:
	print(ar[k - 1])


(a, b) = map(int, input().split())
s = list(map(int, input().split()))
s = [1] + sorted(s)
if a == b or s[b] != s[b + 1]:
	print(s[b])
else:
	print(-1)


(n, k) = list(map(int, input().split()))
seq = list(map(int, input().split()))
seq.sort()
if k == 0 and seq[0] - 1 > 0:
	print(seq[0] - 1)
elif k == n:
	print(max(seq))
elif seq[k - 1] < seq[k]:
	print(seq[k - 1])
else:
	print(-1)


(n, k) = map(int, input().split())
arr = list(sorted(map(int, input().split())))
if n == k:
	print(arr[-1])
elif k == 0 and arr[0] != 1:
	print(1)
elif k == 0 and arr[0] == 1 or arr[k - 1] == arr[k]:
	print(-1)
else:
	print(arr[k - 1])


def main():
	in1 = [int(x) for x in input().split(' ')]
	arr = [int(x) for x in input().split(' ')]
	arr = sorted(arr)
	if in1[0] == in1[1]:
		print(arr[in1[1] - 1])
	elif in1[1] == 0:
		if arr[0] == 1:
			print(-1)
		else:
			print(1)
	elif arr[in1[1] - 1] == arr[in1[1]]:
		print(-1)
	else:
		print(arr[in1[1] - 1])
	return
main()


import bisect
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
p = 0
t1 = -1
for i in range(n):
	if i == k - 1:
		t1 = a[i]
t2 = bisect.bisect_right(a, t1)
t3 = bisect.bisect_right(a, t1 + 1)
t4 = bisect.bisect_right(a, t1 - 1)
if k == 0 and a[0] > 1:
	print(1)
elif t2 == k:
	print(t1)
elif t3 == k:
	print(t1 + 1)
elif t4 == k:
	print(t1 - 1)
else:
	print(-1)


a = input()
b = input()
a = list(map(int, a.split()))
b = list(map(int, b.split()))
n = a[0]
k = a[1]
b.sort()
if k == 0:
	if b[0] != 1:
		res = 1
	else:
		res = -1
elif k == len(b):
	res = b[-1]
elif b[k - 1] == b[k]:
	res = -1
else:
	res = b[k - 1]
print(res)


(n, k) = map(int, input().split())
ls = list(map(int, input().split()))
ls.append(0)
ls.sort()
aa = ls[k]
if aa == 0:
	aa = 1
if k == n:
	print(ls[k])
elif aa == ls[k + 1]:
	print('-1')
else:
	print(aa)


(n, k) = input().split()
n = int(n)
k = int(k)
nums = [int(x) for x in input().split()]
nums.sort()
if k == 0:
	if nums[0] == 1:
		print(-1)
	else:
		print(nums[0] - 1)
elif n == 1:
	print(nums[0])
elif n == k:
	print(1000000000)
elif nums[k - 1] == nums[k]:
	print(-1)
else:
	print(nums[k - 1])


import collections
(n, k) = input().split(' ')
n = int(n)
k = int(k)
vetor = input().split(' ')
contador = {}
min = 10 ** 9
for i in vetor:
	i = int(i)
	if min > i:
		min = i
	if i in contador.keys():
		contador[i] = contador[i] + 1
	else:
		contador[i] = 1
if k == 0 and min > 1:
	print(1)
	exit()
contador = collections.OrderedDict(sorted(contador.items()))
somador = 0
for (key, value) in contador.items():
	somador = somador + value
	if somador == k:
		print(key)
		exit()
print(-1)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if ll[mid] >= val:
			ans = ll[mid]
			return binary(l, mid - 1, ll, val, ans)
		else:
			return binary(mid + 1, r, ll, val, ans)
(n, k) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
l.sort()
if k - 1 == n - 1:
	print(l[k - 1])
elif k == 0:
	if l[0] == 1:
		print(-1)
	else:
		print(1)
elif l[k - 1] == l[k]:
	print(-1)
else:
	print(l[k - 1])


A = input().split()
n = int(A[0])
k = int(A[1])
B = [int(x) for x in input().split()]
B.sort()
if k == 0:
	if B[0] > 1:
		print(1)
	else:
		print(-1)
elif k == n:
	print(B[k - 1])
elif B[k - 1] == B[k]:
	print(-1)
else:
	print(B[k - 1])


import bisect
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = a[k - 1]
if k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(a[0] - 1)
elif bisect.bisect_right(a, ans) == k:
	print(a[k - 1])
else:
	print(-1)


(n, k) = [int(x) for x in input().split(' ')]
z = [int(x) for x in input().split(' ')]
z.sort()
if k == 0:
	if z[0] == 1:
		print(-1)
	else:
		print(1)
elif n == 1:
	print(z[0])
elif k == n:
	print(z[n - 1])
elif z[k - 1] == z[k] and k < n:
	print(-1)
else:
	print(z[k - 1])


inn = input()
n = int(inn.split(' ')[0])
k = int(inn.split(' ')[1])
seq = input()
seq = sorted([int(x) for x in seq.split(' ')])
if k == 0 and seq[0] > 1:
	print(1)
elif k == 0 and seq[0] == 1:
	print(-1)
elif k <= n - 1:
	if seq[k - 1] != seq[k]:
		print(seq[k - 1])
	else:
		print(-1)
elif k == n:
	print(seq[-1])


(n, k) = map(int, input().split())
a = [0] + [int(x) for x in input().split()] + [1000000001]
a.sort()
if a[k + 1] != a[k] and a[k + 1] > 1:
	print(a[k + 1] - 1)
else:
	print(-1)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

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

def si():
	return input().rstrip()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def solve():
	(n, k) = mi()
	a = li()
	a.sort()
	f = dd(int)
	for i in a:
		f[i] += 1
	x = 0
	if k == 0:
		x = min(a)
		if x <= 1:
			x = 0
		print(x - 1)
		return
	for i in set(a):
		x += f[i]
		if x == k:
			print(i)
			return
	print('-1')
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
if k == 0:
	print([-1, a[0] - 1][a[0] >= 2])
else:
	print([-1, a[k - 1]][k == n or a[k] != a[k - 1]])


(n, k) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
l.sort()
if k == 0:
	if l[0] > 1:
		print(1)
	else:
		print(-1)
else:
	try:
		if l[k - 1] == l[k]:
			print(-1)
		else:
			print(l[k - 1])
	except IndexError:
		print(l[k - 1])


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

def arr_inp():
	return [int(x) for x in input().split()]
(n, k) = inp()
a = arr_inp()
a.sort()
if n == k:
	print(a[k - 1])
elif a[k] > a[k - 1]:
	print(a[k - 1])
elif k == 0 and a[k] > 1:
	print(a[k] - 1)
else:
	print(-1)


from bisect import bisect

def main():
	(N, K) = map(int, input().split())
	A = tuple(map(int, input().split()))
	seq = sorted(A)
	x = seq[K - 1] if K else 1
	if bisect(seq, x) == K:
		print(x)
	else:
		print(-1)
main()


import sys, math
from collections import Counter, deque, defaultdict
mod = 10 ** 9 + 7
INF = float('inf')

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

def inpl():
	return list(map(int, sys.stdin.readline().split()))
(n, k) = inpl()
a = inpl()
a.sort()
if k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(1)
	quit()
if k < n and a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k - 1])


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
if k == 0:
	ans = a[0] - 1
else:
	ans = a[k - 1]
cnt = 0
for j in a:
	if j <= ans:
		cnt = cnt + 1
	else:
		break
if cnt == k:
	if ans != 0:
		print(ans)
	else:
		print('-1')
else:
	print('-1')


def read():
	return int(input())

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

def readmap():
	return map(int, input().split())
(N, K) = readmap()
A = readlist()
A.sort()
if K == 0:
	if A[0] == 1:
		print(-1)
		quit()
	else:
		print(1)
		quit()
if K == N:
	print(10 ** 9)
	quit()
if A[K - 1] == A[K]:
	print(-1)
else:
	print(A[K - 1])


def quickSort(alist):
	quickSortHelper(alist, 0, len(alist) - 1)

def quickSortHelper(alist, first, last):
	if first < last:
		splitpoint = partition(alist, first, last)
		quickSortHelper(alist, first, splitpoint - 1)
		quickSortHelper(alist, splitpoint + 1, last)

def partition(alist, first, last):
	pivotvalue = alist[int((first + last) / 2)]
	leftmark = first + 1
	rightmark = last
	done = False
	while not done:
		while leftmark <= rightmark and alist[leftmark] <= pivotvalue:
			leftmark = leftmark + 1
		while alist[rightmark] >= pivotvalue and rightmark >= leftmark:
			rightmark = rightmark - 1
		if rightmark < leftmark:
			done = True
		else:
			temp = alist[leftmark]
			alist[leftmark] = alist[rightmark]
			alist[rightmark] = temp
	temp = alist[first]
	alist[first] = alist[rightmark]
	alist[rightmark] = temp
	return rightmark
(n, k) = map(int, input().split())
alist = [int(x) for x in input().split()]
alist.sort()
if k == 0:
	if alist[0] == 1:
		print(-1)
	else:
		print(alist[0] - 1)
elif k == n:
	print(alist[n - 1])
elif alist[k - 1] == alist[k]:
	print(-1)
else:
	print(alist[k - 1])


def solve(n, k, a):
	a = sorted(a)
	if k == 0:
		if a[0] == 1:
			return -1
		else:
			return 1
	for i in range(n):
		k -= 1
		if k == 0:
			if i == n - 1:
				return a[i]
			elif a[i] + 1 >= a[i + 1]:
				if a[i] == a[i + 1]:
					return -1
				else:
					return a[i]
			else:
				return a[i] + 1
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, k, a))


(n, k) = map(int, input().split(' '))
l = []
if n != 1:
	l = list(map(int, input().split(' ')))
else:
	l.append(int(input()))
l.sort()
res = 0
if k == 0:
	res = l[0] - 1
else:
	res = l[k - 1]
count = 0
for i in range(0, n):
	if l[i] <= res:
		count += 1
if res < 1 or count != k or res > 1000000000:
	print(-1)
else:
	print(res)


(n, k) = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
a.sort()
if k == 0:
	x = a[0] - 1
else:
	x = a[k - 1]
c = 0
for i in a:
	if i <= x:
		c += 1
if c == k and x >= 1:
	print(x)
else:
	print(-1)


import sys
import math

def read_line():
	return sys.stdin.readline()[:-1]

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

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]

def read_float_line():
	return [float(v) for v in sys.stdin.readline().split()]
(n, k) = read_int_line()
a = read_int_line()
a.sort()
ans = a[k - 1]
if k == 0 and a[0] != 1:
	print(1)
elif k == 0 and a[0] == 1:
	print(-1)
elif k < n and a[k - 1] == a[k]:
	print(-1)
else:
	print(ans)


(n, k) = map(int, input().strip().split())
arr = [int(x) for x in input().strip().split()]
arr = sorted(arr)
if k == 0:
	if arr[0] == 1:
		print(-1)
	else:
		print(arr[0] - 1)
elif k == n:
	print(arr[k - 1])
elif arr[k - 1] == arr[k]:
	print(-1)
else:
	print(arr[k - 1])


import sys
data = sys.stdin.readlines()
lis = []
for line in data:
	lis.append(line)
(n, k) = lis[0].split()
(n, k) = (int(n), int(k))
seq = list(map(int, lis[1].split()))
if k == 0:
	m = min(seq)
	if m > 1:
		print(m - 1)
		sys.exit()
	else:
		print(-1)
		sys.exit()
if n == k:
	print(1000000000)
	sys.exit()
seq.sort()
m = seq[k - 1]
if len(seq) == 1:
	if k == 1:
		print(m)
		sys.exit()
	else:
		print(-1)
		sys.exit()
if m == seq[k]:
	print(-1)
else:
	print(m)


(n, k) = map(int, input().split())
l = [1] + sorted(map(int, input().split())) + [int(1000000000.0) + 1]
(a, b) = l[k:k + 2]
print(a if a < b else -1)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
if k == 0 and A[0] > 1:
	print(A[0] - 1)
elif n == 1 and k == 1:
	print(A[0])
elif k == n:
	print(A[-1])
elif A[k] == A[k - 1] or k == 0:
	print('-1')
else:
	print(A[k - 1])


(a, b) = map(int, input().split())
mas = [int(i) for i in input().split()]
mas.sort()
if b == 0:
	if min(mas) - 1 > 0:
		print(min(mas) - 1)
	else:
		print(-1)
elif len(mas) > b and mas[b] == mas[b - 1] or b > len(mas):
	print(-1)
else:
	print(max(mas[0:b]))


final = 1
(num, howmany) = input().split()
num = int(num)
howmany = int(howmany)
numbers = input().split()
for count in range(num):
	numbers[count] = int(numbers[count])
numbers.sort()
i = 0
if howmany == 0 and numbers[0] > 1:
	print('1')
	final = 0
while i < num:
	while i < num - 1 and numbers[i] == numbers[i + 1]:
		i = i + 1
	if i + 1 == howmany:
		print(numbers[i])
		final = 0
	i = i + 1
if final == 1:
	print('-1')


def main():
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	nums = sorted([int(x) for x in input().split(' ')])
	if k == 0:
		if nums[0] == 1:
			return -1
		else:
			return 1
	if k == n:
		return nums[n - 1]
	k -= 1
	if nums[k] == nums[k + 1]:
		return -1
	return nums[k]
print(main())


(n, k) = map(int, input().split())
ai = list(map(int, input().split()))
ai.sort()
ans = None
if k == 0:
	ans = ai[0] - 1
else:
	ans = ai[k - 1]
cnt = 0
for i in ai:
	if i <= ans:
		cnt += 1
if cnt != k or ans not in range(1, 10 ** 9 + 1):
	print(-1)
else:
	print(ans)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
a.insert(0, 1)
a.append(10000000000.0)
if a[k] == a[k + 1]:
	print(-1)
else:
	print(a[k])


from bisect import bisect
from collections import defaultdict
from math import gcd, sqrt, ceil, inf
from collections import Counter
import sys
sys.setrecursionlimit(10 ** 9)
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if k == 0:
	if l[0] == 1:
		print(-1)
		exit()
	else:
		print(1)
		exit()
if n == 1:
	if k == 1:
		print(l[0])
		exit()
	else:
		print(-1)
		exit()
z = l[0]
ha = 1
i = 1
while i < n:
	j = i
	if j >= n:
		break
	while l[j] == z:
		if j < n:
			ha += 1
			j += 1
		if j < n:
			if l[j] != z:
				break
		else:
			break
	if ha == k:
		if z <= 10 ** 9:
			print(z)
			exit()
		else:
			print(-1)
			exit()
	if j < n:
		z = l[j]
	i = j
print(-1)


(n, k) = map(int, input().split())
l = sorted(list(map(int, input().split())))
i = 0
b = []
c = 1
b.append(0)
while i + 1 < n:
	if l[i] != l[i + 1]:
		b.append(c)
		c = c + 1
	else:
		c = c + 1
	i = i + 1
b.append(c)
b.append(n)
if k == 1 and n == 1:
	print(l[0])
elif k == 0 and 1 not in l:
	print(1)
elif k == 0 and 1 in l:
	print(-1)
elif k not in b:
	print(-1)
else:
	print(l[k - 1])


(n, k) = map(int, input().rstrip().split(' '))
k = k - 1
l = list(map(int, input().rstrip().split(' ')))
l.sort()
if k == -1:
	if l[0] == 1:
		print(-1)
	else:
		print(1)
elif k + 1 == n:
	print(l[-1])
else:
	num = l[k]
	if l[k] == l[k + 1]:
		print(-1)
	else:
		print(num)


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
try:
	if b > 0:
		if b == 1:
			if a > 1:
				if l[0] == l[1]:
					print(-1)
				else:
					print(l[0])
			else:
				print(l[0])
		elif b < a:
			if l[b] == l[b - 1]:
				print(-1)
			else:
				print(l[b - 1])
		else:
			print(l[b - 1])
	if b == 0:
		if l[0] - 1 > 0:
			print(l[0] - 1)
		else:
			print(-1)
except:
	print(-1)


(n, k) = map(int, input().split())
l = sorted(list(map(int, input().split())))
c = 0
a = l[0] - 1 if k == 0 else l[k - 1]
for i in l:
	if a >= i:
		c += 1
print(a if c == k and a > 0 else -1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(res, cnt) = (0, 0)
a.sort()
if not k:
	res = a[0] - 1
else:
	res = a[k - 1]
for i in a:
	if i <= res:
		cnt += 1
if cnt != k or res < 1:
	print(-1)
else:
	print(res)


entrada1 = input().split(' ')
entrada2 = input().split(' ')
k = int(entrada1[1])
for i in range(len(entrada2)):
	entrada2[i] = int(entrada2[i])
entrada2 = sorted(entrada2)
if k == 0:
	saida = entrada2[0] - 1
else:
	saida = entrada2[k - 1]
contador = 0
for i in entrada2:
	if i <= saida:
		contador += 1
	else:
		break
if saida < 1 or contador != k:
	print(-1)
else:
	print(saida)


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
if k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(1)
elif k == n:
	print(10 ** 9)
elif a[k] == a[k - 1]:
	print(-1)
else:
	print(a[k - 1])


class Solution:

	def __init__(self):
		(self.n, self.k) = [int(x) for x in input().split()]
		self.a = [int(x) for x in input().split()]

	def solve_and_print(self):
		self.a.sort()
		if not self.k:
			if self.a[0] != 1:
				print(self.a[0] - 1)
			else:
				print(-1)
		elif self.k < self.n and self.a[self.k] == self.a[self.k - 1]:
			print(-1)
		else:
			print(self.a[self.k - 1])
Solution().solve_and_print()


(z, zz, dgraphs) = (input, lambda : list(map(int, z().split())), {})
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(n, k) = zz()
l = [1] + sorted(zz())
if k == n or l[k + 1] - l[k]:
	print(l[k])
else:
	print(-1)


k = int(input().strip().split()[-1])
n = [int(x) for x in input().strip().split()]
n.sort()
if k == len(n):
	print(n[k - 1])
elif k == 0:
	if n[0] < 2:
		print(-1)
	else:
		print(n[0] - 1)
else:
	(n1, n2) = (n[k - 1], n[k])
	if n1 != n2:
		print(n[k - 1])
	else:
		print(-1)


from collections import defaultdict
MyDict = defaultdict(int)
X = list(map(int, input().split()))
for i in list(map(int, input().split())):
	MyDict[i] += 1
if X[1] == 0 and min(MyDict.keys()) != 1:
	print(1)
	exit()
for key in sorted(MyDict.keys()):
	X[1] -= MyDict[key]
	if X[1] == 0:
		print(key)
		exit()
	if X[1] < 0:
		print(-1)
		exit()


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, k) = M()
l = L()
l.sort()
if k > n:
	print(-1)
elif k == 0:
	w = l[0]
	if w == 1:
		print(-1)
	else:
		print(w - 1)
elif k == n:
	print(l[-1])
elif l[k - 1] == l[k]:
	print(-1)
else:
	print(l[k - 1])


nklist = list(map(int, input().split()))
dlist = list(map(int, input().split()))
dlist.sort()
k = nklist[1]
if nklist[0] == k:
	print(dlist[k - 1])
elif k == 0:
	if dlist[0] == 1:
		print('-1')
	else:
		print('1')
elif dlist[k] == dlist[k - 1]:
	print('-1')
else:
	print(dlist[k - 1])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if not k == 0:
	print(a[k - 1]) if k == n or not a[k - 1] == a[k] else print(-1)
else:
	print(-1) if 1 in a else print(1)


nk = input().split()
n = int(nk[0])
k = int(nk[1])
s = input().split()
a = []
for x in s:
	a.append(int(x))
a.sort()
ans = -1
if k > 0 and k < n:
	if a[k - 1] < a[k]:
		ans = a[k - 1]
elif k > 0:
	ans = a[n - 1]
elif k < n:
	if a[0] > 1:
		ans = a[0] - 1
print(ans)


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=False)
index = k - 1
if n == k:
	print(L[index])
elif k == 0:
	if L[0] - 1 < 1:
		print(-1)
	else:
		print(L[0] - 1)
elif L[index + 1] == L[index]:
	print(-1)
else:
	print(L[index])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

def solve(a, k):
	if k == 0:
		return -1 if a[0] == 1 else a[0] - 1
	b = a[k:]
	u = a[k - 1]
	for i in b:
		if u >= i:
			return -1
	else:
		return u
print(solve(a, k))


(n, k) = map(int, input().split())
mas = list(map(int, input().split()))
mas.sort()
now = mas[k - 1]
if k == 0:
	if mas[0] != 1:
		print(1)
	else:
		print(-1)
elif k == n or now != mas[k]:
	print(now)
else:
	print(-1)


(n, k) = map(int, str(input()).split())
x = list(map(int, str(input()).split()))
x.sort()
res = -1
if k == n:
	res = x[-1]
elif k == 0:
	res = x[0] - 1
elif x[k - 1] != x[k]:
	res = x[k - 1]
if res < 1 or res > 1000000000:
	print(-1)
else:
	print(res)


(x, y) = map(int, input().split())
z = list(map(int, input().split()))
z.sort()
z.append(0)
if y == 0 and z[0] > 1:
	print(1)
elif z[y - 1] == z[y] or y == 0:
	print(-1)
else:
	print(z[y - 1])


import random
f = input().split(' ')
n = int(f[0])
k = int(f[1])
c = input().replace('\n', '').split(' ')
f = [int(c[i]) for i in range(0, n)]

def quicksel(L, k):
	piv = random.choice(L)
	ls = [x for x in L if x < piv]
	eq = [x for x in L if x == piv]
	gr = [x for x in L if x > piv]
	if k <= len(ls):
		return quicksel(ls, k)
	elif k <= len(ls) + len(eq):
		return eq[0]
	else:
		return quicksel(gr, k - len(ls) - len(eq))
if k != 0:
	x = quicksel(f, k)
else:
	x = quicksel(f, 1) - 1
cnt = 0
for i in f:
	if i <= x:
		cnt += 1
if cnt != k or x < 1 or x > 10 ** 9:
	print(-1)
else:
	print(x)


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
try:
	if k == n:
		print(a[k - 1])
	elif k == 0:
		if a[0] == 1:
			print(-1)
		else:
			print(1)
	elif a[k - 1] == a[k]:
		print(-1)
	else:
		print(a[k - 1])
except:
	print(-1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
if k == 0:
	num = a[0] - 1
	if num >= 1 and num <= 10 ** 9:
		print(num)
	else:
		print('-1')
elif k == n:
	num = a[n - 1]
	print(num)
elif a[k - 1] == a[k]:
	print('-1')
else:
	print(a[k - 1])


(_, k) = tuple(map(int, input().split()))
num = list(map(int, input().split()))
num.sort()
if k == 0 and num[0] != 1:
	print(num[0] - 1)
elif k == 0 and num[0] == 1:
	print(-1)
elif k == len(num) or num[k - 1] != num[k]:
	print(num[k - 1])
else:
	print(-1)


(n, k) = input().split()
(n, k) = (int(n), int(k))
l = [int(n) for n in input().split()]
l.sort()
(first, second) = (l[k - 1], 1000000000)
if k < n:
	second = l[k]
if k == 0:
	if l[0] > 1:
		print(1)
	else:
		print(-1)
elif n == k:
	print(first)
elif first == second:
	print(-1)
else:
	print(first)


(n, line) = map(int, input().split())
nums = list(map(int, input().split(' ')))
nums.sort()
a = 0
flag = -1
if line > 1:
	if line == n:
		flag = nums[line - 1]
	elif nums[line] - 1 >= nums[line - 1]:
		if nums[line - 1] == 1000000000:
			flag = 1000000000
		else:
			flag = nums[line - 1]
elif line == 1:
	if n == 1:
		if nums[line - 1] == 1000000000:
			flag = 1000000000
		else:
			flag = nums[0]
	elif nums[line] - 1 >= nums[line - 1]:
		flag = nums[0]
elif line == 0:
	if n == 1:
		if nums[0] >= 2:
			flag = nums[0] - 1
	elif nums[0] - 1 == 0:
		flag = -1
	else:
		flag = nums[0] - 1
print(flag)


import heapq
(n, k) = list(map(int, input().split()))
li = list(map(int, input().split()))
heapq.heapify(li)
if k == 0:
	if heapq.heappop(li) != 1:
		print('1')
	else:
		print('-1')
if k >= 1:
	for i in range(k):
		x = heapq.heappop(li)
	if len(li) >= 1 and heapq.heappop(li) == x:
		print('-1')
	else:
		print(x)


(num_length, k_elements) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
if k_elements - 1 < 0:
	if arr[0] - 1 >= 1:
		print(arr[0] - arr[0] + 1)
	else:
		print(-1)
else:
	candidate = arr[k_elements - 1]
	try:
		if arr[k_elements] == candidate:
			print(-1)
		else:
			print(candidate)
	except:
		print(candidate)


(n, k) = map(int, input().split())
a = list(sorted(map(int, input().split())))
ans = 0
if k == 0:
	ans = a[0] - 1
else:
	ans = a[k - 1]
i = 0
while i < n and a[i] <= ans:
	i += 1
if ans < 1 or i != k:
	ans = -1
print(ans)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
temp = [1]
temp.extend(l)
if k == n or temp[k + 1] != temp[k]:
	print(temp[k])
else:
	print(-1)


(n, k) = list(map(int, input().strip().split(' ')))
nums = list(map(int, input().strip().split(' ')))
nums.sort()
if k == n:
	print(nums[-1])
elif k == 0:
	if 1 <= nums[0] - 1:
		print(nums[0] - 1)
	else:
		print(-1)
else:
	currn = nums[k - 1]
	if nums[k] > currn:
		print(currn)
	else:
		print(-1)


(n, k) = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]
d.sort()
if k == 0:
	if d[0] == 1:
		print(-1)
	else:
		print(1)
elif k == n:
	print(10 ** 9)
else:
	dk = d[k - 1]
	if d[k] == dk:
		print(-1)
	else:
		print(dk)


def solve(k, sequence):
	if k == 0:
		value = min(sequence) - 1
		return value if 1 <= value <= 10 ** 9 else -1
	sequence = sorted(sequence)
	value = sequence[k - 1]
	return value if len([x for x in sequence if x <= value]) == k else -1

def main():
	(_, k) = [int(x) for x in input().strip().split()]
	sequence = [int(x) for x in input().strip().split()]
	result = solve(k, sequence)
	print(result)
main()


from collections import *
import sys
input = lambda : sys.stdin.readline().strip()
orddict = OrderedDict
defdict = defaultdict
counter = Counter

def nextint():
	return int(input())

def snexts():
	return input().split(' ')

def snextint():
	return map(int, snexts())
(n, k) = snextint()
lis = map(int, input().split())
dic = defaultdict(int)
lismin = 2000000000
for i in lis:
	lismin = min(lismin, i)
	dic[i] += 1
tups = sorted(dic.items())
curr = 0
corv = -1
if k == 0:
	if lismin > 1:
		print(lismin - 1)
	else:
		print(-1)
else:
	for (kk, v) in tups:
		curr += v
		if curr == k:
			corv = kk
			break
		elif curr > k:
			break
	print(corv)


import os
import sys
from math import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

def array():
	return [int(i) for i in input().split()]
(n, k) = value()
a = sorted(array())
if k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(1)
	exit()
if k < n and a[k - 1] < a[k]:
	print(a[k - 1])
elif k == n:
	print(a[-1])
else:
	print(-1)


k = int(input().split()[1])
l = sorted([int(s) for s in input().split()])
if k == 0:
	print(-1 if l[0] == 1 else l[0] - 1)
elif k > len(l) or (k != len(l) and l[k] == l[k - 1]):
	print(-1)
else:
	print(l[k - 1])


def pr(ans):
	ss = 0
	for x in a:
		if x <= ans:
			ss

def check(x):
	if 1 <= x <= 10 ** 9:
		return x
	else:
		return -1
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(a[0] - 1)
else:
	k -= 1
	if a.count(a[k]) == 1:
		if k + 1 < n:
			print(check(a[k]))
		else:
			print(check(a[k]))
	elif k + 1 < n:
		if a[k + 1] == a[k]:
			print(-1)
		else:
			print(check(a[k]))
	else:
		print(check(a[k]))


(n, k) = [int(i) for i in input().strip().split()]
arr = [int(i) for i in input().strip().split()]
arr.sort()
ans = -1
if k == n:
	ans = arr[k - 1]
else:
	ans = arr[k] - 1
if ans == 0:
	ans = -1
if k > 0:
	if ans < arr[k - 1]:
		ans = -1
print(ans)


(n, k) = list(map(int, input().split()))
aa = list(map(int, input().split()))
aa.sort()
if k == 0:
	if aa[0] == 1:
		print(-1)
	else:
		print(1)
elif k == n or aa[k - 1] < aa[k]:
	print(aa[k - 1])
else:
	print(-1)


from collections import defaultdict as dd
(n, k) = [int(i) for i in input().split(' ')]
l = [int(i) for i in input().split(' ')]
if k == 0:
	ans = 1
	for i in range(n):
		if l[i] == 1:
			ans = -1
	print(ans)
elif k == n:
	print(1000000000)
else:
	l.sort()
	if l[k] == l[k - 1]:
		print(-1)
	else:
		print(l[k - 1])


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
(n, k) = mints()
a = list(mints())
a.sort()
if k == 0:
	if a[0] == 1:
		print(-1)
	else:
		print(1)
elif k < n and a[k - 1] == a[k]:
	print(-1)
else:
	print(a[k - 1])


import heapq
a = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
arr.sort()
if a[1] == 0:
	ans = arr[0] - 1
else:
	ans = arr[a[1] - 1]
cnt = 0
for i in arr:
	if i <= ans:
		cnt += 1
if cnt != a[1] or ans < 1:
	print(-1)
else:
	print(ans)


def check(arr, k):
	if k == 0 and arr[0] > 1:
		return 1
	elif k == 0 and arr[0] == 1:
		return -1
	elif k <= n - 1:
		if arr[k] != arr[k - 1]:
			return arr[k - 1]
		return -1
	elif k == n:
		return arr[k - 1]
(n, k) = map(int, input().split())
arr = sorted(list(map(int, input().split())))
print(check(arr, k))


(a, b) = map(int, input().split())
d = []
n = 0
k = 0
c = list(map(int, input().split()))
c = sorted(c)
if b == 0:
	if c[0] != 1:
		print(1)
	else:
		print(-1)
elif b < len(c) and c[b] == c[b - 1]:
	print(-1)
else:
	print(c[b - 1])


(a, b) = map(int, input().split())
l = sorted(list(map(int, input().split())))
if a == b:
	print(l[b - 1])
elif b == 0 and l[0] >= 2:
	print(l[0] - 1)
elif b == 0 and l[0] <= 1:
	print(-1)
elif l[b] == l[b - 1]:
	print(-1)
else:
	print(l[b - 1])


(n, k) = map(int, input().split())
li = sorted(list(map(int, input().split())))
cnt = 0
if k == 0:
	print(-1 if li[0] == 1 else li[0] - 1)
elif k == n:
	print(li[n - 1])
elif li[k - 1] == li[k]:
	print(-1)
else:
	print(li[k - 1])


inp = input()
(n, k) = inp.split(' ')
n = int(n)
k = int(k)
numbers = input().split(' ')
for i in range(len(numbers)):
	numbers[i] = int(numbers[i])
numbers.sort()
if n == 1:
	if k == 0:
		if numbers[0] > 1:
			print(1)
		else:
			print(-1)
	else:
		print(numbers[0])
elif k == n:
	print(numbers[k - 1])
elif k == 0 and numbers[0] > 1:
	print(1)
elif k == 0 or numbers[k - 1] == numbers[k]:
	print(-1)
else:
	print(numbers[k - 1])


import sys
(n, k) = (int(elem) for elem in sys.stdin.readline().split())
uinput = (int(elem) for elem in sys.stdin.readline().split())
input = sorted(uinput)
if k == 0:
	print(input[0] - 1 or -1)
elif k == n:
	print(input[n - 1])
elif input[k] == input[k - 1]:
	print(-1)
else:
	print(input[k - 1])


(n, k) = map(int, input().split())
t = list(map(int, input().split()))
t.sort()
t = t[::-1]
d = {}
for i in t:
	if d.get(i) == None:
		d[i] = 1
	else:
		d[i] += 1
s = 0
a = 0
while d != {} and s < k:
	l = d.popitem()
	s += l[1]
	a = l[0]
if k == 0 and t[-1] != 1:
	print(1)
elif s == k and k != 0:
	print(a)
else:
	print(-1)