Ashish has an array $a$ of size $n$.

A subsequence of $a$ is defined as a sequence that can be obtained from $a$ by deleting some elements (possibly none), without changing the order of the remaining elements.

Consider a subsequence $s$ of $a$. He defines the cost of $s$ as the minimum between:   The maximum among all elements at odd indices of $s$.  The maximum among all elements at even indices of $s$. 

Note that the index of an element is its index in $s$, rather than its index in $a$. The positions are numbered from $1$. So, the cost of $s$ is equal to $min(max(s_1, s_3, s_5, \ldots), max(s_2, s_4, s_6, \ldots))$.

For example, the cost of $\{7, 5, 6\}$ is $min( max(7, 6), max(5) ) = min(7, 5) = 5$.

Help him find the minimum cost of a subsequence of size $k$.


-----Input-----

The first line contains two integers $n$ and $k$ ($2 \leq k \leq n \leq 2 \cdot 10^5$)  — the size of the array $a$ and the size of the subsequence.

The next line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 10^9$)  — the elements of the array $a$.


-----Output-----

Output a single integer  — the minimum cost of a subsequence of size $k$.


-----Examples-----
Input
4 2
1 2 3 4

Output
1
Input
4 3
1 2 3 4

Output
2
Input
5 3
5 3 4 2 6

Output
2
Input
6 4
5 3 50 2 4 5

Output
3


-----Note-----

In the first test, consider the subsequence $s$ = $\{1, 3\}$. Here the cost is equal to $min(max(1), max(3)) = 1$.

In the second test, consider the subsequence $s$ = $\{1, 2, 4\}$. Here the cost is equal to $min(max(1, 4), max(2)) = 2$.

In the fourth test, consider the subsequence $s$ = $\{3, 50, 2, 4\}$. Here the cost is equal to $min(max(3, 2), max(50, 4)) = 3$.

Difficulty: interview

Starter code:

Solutions:
n, k = map(int,input().split())
lo = 0#Imposs
hi = 10 ** 9#Poss


l = list(map(int, input().split()))

while hi - lo > 1:
    test = lo + (hi - lo)//2

    odd = 0
    skip = False

    for v in l:
        if skip:
            skip = False
            odd += 1
        else:
            if v <= test:
                odd += 1
                skip = True

    even = 0
    skip = True

    for v in l:
        if skip:
            skip = False
            even += 1
        else:
            if v <= test:
                even += 1
                skip = True

    if odd >= k or even >= k:
        hi = test
    else:
        lo = test

print(hi)

def subsolve(a, x):
    c = 0
    i = 0
    while i < len(a):
        if a[i] > x:
            i += 1
            continue
        j = i
        while j < len(a) and a[j] <= x:
            j += 1
        c += (j - i) // 2 + (j - i) % 2
        i = j
    return c

def odd(n, k, a):
    if k >= 2 and k % 2 == 0:
        a = a[:-1]
    l, r = 0, max(a) + 1
    while r - l > 1:
        mid = (l + r) // 2
        if subsolve(a, mid) >= k // 2 + k % 2:
            r = mid
        else:
            l = mid
    return r

def even(n, k, a):
    if k == 1:
        return max(a) + 1
    a = a[1:]
    if k % 2 == 1:
        a.pop(-1)
    l, r = 0, max(a) + 1
    while r - l > 1:
        mid = (l + r) // 2
        if subsolve(a, mid) >= k // 2:
            r = mid
        else:
            l = mid
    return r

def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    print(min(odd(n, k, a), even(n, k, a)))

solve()

def check(num):
	count = 0
	flag = -1
	s = 0
	for i in range(n):
		if a[i]<=num:
			count += 1
			s += 1
		else:
			if flag == -1:
				flag = s%2
				count += 1
				s += 1
			else:
				if (s+1)%2!=flag:
					count += 1
					s += 1
		if count==k:
			return True
	return False

n,k = map(int,input().split())
a = list(map(int,input().split()))
if n==k:
	m1 = 0
	m2 = 0
	for i in range(0,n,2):
		m1 = max(m1,a[i])
	for i in range(1,n,2):
		m2 = max(m2,a[i])
	print (min(m1,m2))
	return
s = set(a)
minn,maxx = min(a),max(a)
low = minn
high = maxx
while low<high:
	mid = (low+high)//2
	if check(mid):
		high = mid-1
	else:
		low = mid+1
if check(low):
	print (low)
else:
	print (low+1)