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: HARD
Tags: Sorting

Implementation

Greedy algorithms

Dynamic programming

Spanning trees
Skill types: Dynamic programming

Sorting

Greedy algorithms

Starter code:

Solutions:
import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = a.copy()
b.sort()
low = 0
high = len(b) - 1
mid = len(b) // 2
answer1 = 10 ** 10
while low <= high:
	need = k // 2
	if k % 2 == 0:
		mom = len(a)
	else:
		mom = len(a) - 1
	ans = b[mid]
	i = 1
	while need > 0 and i < mom:
		if a[i] <= ans:
			need -= 1
			i += 2
		else:
			i += 1
	if need == 0:
		answer1 = min(answer1, ans)
	if need > 0:
		low = mid + 1
	else:
		high = mid - 1
	mid = (low + high) // 2
low = 0
high = len(b) - 1
mid = len(b) // 2
answer2 = 10 ** 10
while low <= high:
	need = k // 2 + k % 2
	ans = b[mid]
	i = 0
	mam = 0
	if k % 2 == 0:
		mam = len(a) - 1
	else:
		mam = len(a)
	while need > 0 and i < mam:
		if a[i] <= ans:
			need -= 1
			i += 2
		else:
			i += 1
	if need == 0:
		answer2 = min(answer2, ans)
	if need > 0:
		low = mid + 1
	else:
		high = mid - 1
	mid = (low + high) // 2
print(min(answer1, answer2))


def valid(m, even=True):
	l = 0
	for i in range(n):
		if not even:
			l += 1
			even = not even
		elif a[i] <= m:
			l += 1
			even = not even
	return l >= k
(n, k) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
l = 1
h = 1000000000.0
while l < h:
	m = l + (h - l) // 2
	if valid(m, even=True) or valid(m, even=False):
		h = m
	else:
		l = m + 1
print(int(h))


import math

def ok(a, cantidad, cota):
	ans = []
	for i in range(len(a)):
		if a[i] <= cota:
			if not ans or ans[-1] < i - 1:
				ans.append(i)
	return len(ans) >= cantidad
(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
impares = math.ceil(k / 2)
pares = int(k / 2)
(l, r) = (min(a), 10 ** 9 + 5)
ans = r
while l <= r:
	mid = (l + r) // 2
	if k & 1:
		if ok(a, impares, mid) or ok(a[1:-1], pares, mid):
			ans = mid
			r = mid - 1
		else:
			l = mid + 1
	elif ok(a[:-1], impares, mid) or ok(a[1:], pares, mid):
		ans = mid
		r = mid - 1
	else:
		l = mid + 1
print(ans)


def main():
	(n, k) = [int(s) for s in input().split()]
	a = [int(s) for s in input().split()]
	low = min(a)
	high = max(a)
	while low < high:
		mid = (low + high) // 2
		if possible(a, k, mid):
			high = mid
		else:
			low = mid + 1
	print(low)

def possible(a, k, x):
	return greedy(a, k, x, 0) or greedy(a, k, x, 1)

def greedy(a, k, x, parity):
	i = 0
	s = []
	while i < len(a) and len(s) < k:
		if len(s) % 2 == parity:
			if a[i] <= x:
				s.append(a[i])
		else:
			s.append(a[i])
		i += 1
	return len(s) == k
main()


def check(x, n):
	global k
	count = 0
	for e in arr:
		if e <= x and count % 2 == n:
			count += 1
		elif count % 2 != n:
			count += 1
		if count == k:
			return True
	return False
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
l = 1
r = 10 ** 9
while l < r:
	mid = (l + r) // 2
	if check(mid, 0) or check(mid, 1):
		r = mid
	else:
		l = mid + 1
print(l)


import sys
input = sys.stdin.readline
from collections import *

def judge(x):
	f = [0] * n
	for i in range(n):
		if a[i] <= b[x]:
			f[i] = 1
	if f[0] == 1:
		flag = False
		(c1, c2) = (0, 0)
		for i in range(n):
			if f[i] == 1 and (not flag):
				c1 += 1
				flag = True
			elif flag:
				c2 += 1
				flag = False
		if c1 >= (k + 1) // 2 and c2 >= k // 2:
			return True
	flag = False
	(c1, c2) = (0, 1)
	for i in range(1, n):
		if f[i] == 1 and (not flag):
			c1 += 1
			flag = True
		elif flag:
			c2 += 1
			flag = False
	if c1 >= k // 2 and c2 >= (k + 1) // 2:
		return True
	else:
		return False

def binary_search():
	(l, r) = (0, n - 1)
	while l <= r:
		m = (l + r) // 2
		if judge(m):
			r = m - 1
		else:
			l = m + 1
	return l
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = a[:]
b.sort()
idx = binary_search()
print(b[idx])


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def get_str():
	return input().decode().strip()

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

def oint():
	return int(input())

def check(th, skip):
	l = 0
	for i in range(n):
		if skip:
			skip = 0
			l += 1
			continue
		if a[i] <= th:
			l += 1
			skip = 1
	return l >= k
(n, k) = rint()
a = list(rint())
a2 = list(set(a[:]))
a2.sort()
n2 = len(a2)
lo = 0
hi = n2 - 1
while hi - lo >= 1:
	mid = lo + (hi - lo) // 2
	if check(a2[mid], 0) or check(a2[mid], 1):
		hi = mid
	else:
		lo = mid + 1
print(a2[hi])


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

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	(n, k) = RL()
	arr = RLL()
	(l, r) = (0, max(arr))

	def c(num, flg):
		now = 0
		for i in range(n):
			if flg or arr[i] <= num:
				flg ^= 1
				now += 1
		return now >= k
	while l < r:
		m = (l + r) // 2
		if c(m, 0) or c(m, 1):
			r = m
		else:
			l = m + 1
	print(l)
main()


(n, k) = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

def check_possible(array, x):
	i = 0
	removed = 0
	while i < n:
		if array[i] <= x:
			i += 2
		else:
			i += 1
			removed += 1
	odd = removed <= n - k
	i = 1
	removed = 0
	while i < n:
		if array[i] <= x:
			i += 2
		else:
			i += 1
			removed += 1
	even = removed <= n - k
	return odd or even
x_min = 1
x_max = 1000000001
while x_max - x_min > 1:
	if (x_max + x_min) % 2 == 0:
		x_mid = (x_max + x_min) // 2
	else:
		x_mid = (x_max + x_min - 1) // 2
	if check_possible(array, x_mid):
		x_max = x_mid
	else:
		x_min = x_mid
if check_possible(array, x_min):
	print(x_min)
else:
	print(x_max)


import os, sys
from io import BytesIO, IOBase

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	(hi, lo) = (10 ** 9, 0)
	while hi >= lo:
		mid = (hi + lo) // 2
		cou = 0
		cou1 = 0
		for i in range(n):
			if a[i] <= mid and (not cou % 2):
				cou += 1
			elif cou % 2:
				cou += 1
			if a[i] <= mid and cou1 % 2:
				cou1 += 1
			elif not cou1 % 2:
				cou1 += 1
			if cou == k or cou1 == k:
				break
		if cou == k or cou1 == k:
			hi = mid - 1
			fl = 0
		else:
			lo = mid + 1
			fl = 1
	print(mid + fl)
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')
main()


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

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

def fi():
	return int(input())

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

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

def gh():
	sys.stdout.flush()

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)

def bo(i):
	return ord(i) - ord('a')

def oro(a):

	def can(mid, c):
		res = 0
		for i in range(n):
			if c or a[i] <= mid:
				res += 1
				c ^= 1
		return res >= k
	b = sorted(a)
	l = 0
	r = n - 1
	ans = 0
	while l <= r:
		mid = (l + r) // 2
		if can(b[mid], 0) or can(b[mid], 1):
			ans = b[mid]
			r = mid - 1
		else:
			l = mid + 1
	print(ans)

def find(a, i):
	if a[i] == i:
		return i
	a[i] = find(a, a[i])
	return a[i]

def union(a, x, y):
	xs = find(a, x)
	ys = find(a, y)
	if size[xs] < size[ys]:
		(xs, ys) = (ys, xs)
	size[xs] += size[ys]
	a[ys] = xs
(n, k) = mi()
a = li()
oro(a)


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

def bs(mid, s, k):
	count = 0
	for i in range(n):
		if s or a[i] <= mid:
			count += 1
			s ^= 1
	if count >= k:
		return True
	return False
left = 0
right = 1000000000.0
while left < right:
	mid = int(left + right) // 2
	if bs(mid, 0, k) or bs(mid, 1, k):
		right = mid
	else:
		left = mid + 1
print(left)


from collections import defaultdict

def ok(mid, flag, k, a):
	ans = 0
	for ele in a:
		if flag:
			if ele <= mid:
				ans += 1
				flag ^= 1
		else:
			flag ^= 1
			ans += 1
	return ans >= k

def solve():
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	(start, end) = (1, 10 ** 9)
	while start < end:
		mid = start + end
		mid >>= 1
		if ok(mid, 0, k, a) or ok(mid, 1, k, a):
			end = mid
		else:
			start = mid + 1
	print(start)
t = 1
for _ in range(t):
	solve()


def fun(mid):
	global ar, k
	cur1 = 0
	cur2 = 0
	for i in ar:
		if i <= mid or cur1 % 2 == 0:
			cur1 += 1
		if i <= mid or cur2 % 2 != 0:
			cur2 += 1
	f1 = bool(cur1 >= k)
	f2 = bool(cur2 >= k)
	return f1 or f2
(n, k) = map(int, input().split())
ar = list(map(int, input().split()))
l = 0
r = max(ar)
while l < r:
	mid = (l + r) // 2
	if fun(mid):
		r = mid
	else:
		l = mid + 1
print(l)


def check(amin, r):
	cnt = 0
	for i in range(n):
		if a[i] <= amin or cnt % 2 == r:
			cnt += 1
	return cnt >= k
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = int(1000000000.0)
while r - l > 1:
	m = (l + r) // 2
	if check(m, 0) or check(m, 1):
		r = m
	else:
		l = m
print(r)


def is_possible(val, arr, k):
	count = 0
	just_added = False
	for el in arr:
		if el > val:
			just_added = False
		elif not just_added:
			just_added = True
			count += 1
			if count == k:
				return True
		else:
			just_added = False
	return False

def binary_search(possible_sorted_answers, arr, to_pick):
	left = 0
	right = len(possible_sorted_answers)
	while True:
		x = (left + right) // 2
		p1 = is_possible(possible_sorted_answers[x], arr, to_pick)
		if p1 and x == 0:
			return possible_sorted_answers[0]
		elif p1:
			right = x
		elif x == len(possible_sorted_answers) - 1:
			return possible_sorted_answers[-1]
		else:
			p2 = is_possible(possible_sorted_answers[x + 1], arr, to_pick)
			if p2:
				return possible_sorted_answers[x + 1]
			else:
				left = x
import sys

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

def input_split():
	return [int(i) for i in input().split()]
(n, k) = input_split()
arr = input_split()
arr_sorted = arr.copy()
arr_sorted.sort()
possible_sorted_answers = arr_sorted[k // 2 - 1:k]
if k % 2 == 0:
	ans = min(binary_search(possible_sorted_answers, arr[:-1], k // 2), binary_search(possible_sorted_answers, arr[1:], k // 2))
else:
	ans = min(binary_search(possible_sorted_answers, arr[1:-1], k // 2), binary_search(possible_sorted_answers, arr, k // 2 + 1))
print(ans)


from os import path
import sys
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()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
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')

def solve():
	(n, k) = mi()
	a = li()

	def can(m, f):
		ans = 0
		for i in range(n):
			if f == 0:
				ans += 1
				f ^= 1
			elif a[i] <= m:
				ans += 1
				f ^= 1
		return ans >= k
	l = 1
	r = int(1000000000.0 + 5)
	while l <= r:
		m = l + (r - l) // 2
		if can(m, 0) or can(m, 1):
			ans = m
			r = m - 1
		else:
			l = m + 1
	print(ans)
solve()


def fun(m):
	global a1, k
	c1 = 0
	c2 = 0
	for i in a1:
		if i <= m or c1 % 2 == 0:
			c1 += 1
		if i <= m or c2 % 2 != 0:
			c2 += 1
	f1 = bool(c1 >= k)
	f2 = bool(c2 >= k)
	return f1 or f2
(n, k) = map(int, input().split())
a1 = list(map(int, input().split()))
l = 0
b = max(a1)
while l < b:
	m = (l + b) // 2
	if fun(m):
		b = m
	else:
		l = m + 1
print(l)


def check(x, flag) -> bool:
	l = 0
	for i in range(len(a)):
		if flag or a[i] <= x:
			l += 1
			flag ^= 1
	return l >= k
(n, k) = input().split()
n = int(n)
k = int(k)
a = [int(n) for n in input().split()]
l = 0
r = 1000000007
while l + 1 < r:
	mid = l + r >> 1
	if check(mid, 0) or check(mid, 1):
		r = mid
	else:
		l = mid
print(r)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
end = max(A)
beg = min(A)
while beg < end:
	mid = (beg + end) // 2
	oc = 0
	ec = 0
	for i in range(n):
		if oc % 2 == 0 or A[i] <= mid:
			oc = oc + 1
		if ec % 2 != 0 or A[i] <= mid:
			ec = ec + 1
	if ec >= k or oc >= k:
		end = mid
	else:
		beg = mid + 1
print(beg)


import os
from io import BytesIO, IOBase
import sys
from collections import Counter
from math import sqrt, pi, ceil, log, inf, gcd, floor

def check(a, mid, t):
	l = 0
	for i in range(len(a)):
		if t:
			if l % 2 and a[i] <= mid:
				l += 1
			elif not l % 2:
				l += 1
		elif not l % 2 and a[i] <= mid:
			l += 1
		elif l % 2:
			l += 1
	return l

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	lo = min(a)
	hi = max(a)
	mi = inf
	while lo <= hi:
		mid = (lo + hi) // 2
		e = max(check(a, mid, 0), check(a, mid, 1))
		if e >= k:
			mi = min(mid, mi)
			hi = mid - 1
		else:
			lo = mid + 1
	print(mi)
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')
main()


def find(s, num, arr, k):
	l = 0
	for i in range(len(arr)):
		if s == 1 or arr[i] <= num:
			s = 1 - s
			l += 1
	return l >= k
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
(l, r) = (1, max(arr))
while l < r:
	mid = (l + r) // 2
	if find(0, mid, arr, k) or find(1, mid, arr, k):
		r = mid
	else:
		l = mid + 1
print(l)


l = lambda : map(int, input().split())
(n, k) = l()
a = list(l())

def check(x, cur):
	ans = 0
	for i in range(n):
		if cur == 0:
			ans += 1
			cur = 1
		elif a[i] <= x:
			ans += 1
			cur = 0
	return ans >= k
lo = 1
hi = int(1000000000.0)
while lo < hi:
	mid = (lo + hi) // 2
	if check(mid, 0) or check(mid, 1):
		hi = mid
	else:
		lo = mid + 1
print(lo)


def w(n):
	return n // 2 + n % 2

def main():
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	e = list(sorted(enumerate(a), key=lambda x: x[1]))
	d = 0
	b = [False] * n
	for i in range(n):
		(idx, val) = e[i]
		left = 0
		while idx - left - 1 >= 0 and b[idx - left - 1]:
			left += 1
		right = 0
		while idx + right + 1 < n and b[idx + right + 1]:
			right += 1
		d += w(left + 1 + right) - w(left) - w(right)
		b[idx] = True
		if d >= k // 2:
			if d >= k // 2 + 1:
				return val
			first = 0
			while b[first]:
				first += 1
			last = 0
			while b[-last - 1]:
				last += 1
			if k % 2 == 0:
				if first % 2 == 0 or last % 2 == 0:
					return val
			elif first % 2 == 0 and last % 2 == 0:
				return val
print(main())


import atexit
import io
import sys
import math
from collections import defaultdict, Counter

def find(m, n):
	kk = 0
	global k
	for j in range(n):
		if kk % 2 == 0:
			kk += 1
		elif a[j] <= m:
			kk += 1
	if kk >= k:
		return 1
	kk = 0
	for j in range(n):
		if kk & 1 == 1:
			kk += 1
		elif a[j] <= m:
			kk += 1
	if kk >= k:
		return 1
	else:
		return 0
for i in range(1):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mi = 1000000000
	ma = 0
	for j in a:
		mi = min(mi, j)
		ma = max(ma, j)
	while mi <= ma:
		mid = (mi + ma) // 2
		if find(mid, n):
			ma = mid - 1
		else:
			mi = mid + 1
	print(mi)


def check(x, p):
	c = 0
	for i in range(n):
		if a[i] <= x or c % 2 == p:
			c += 1
		if c == k:
			return True
	return False
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(l, r) = (min(a), max(a))
ans = r
while l <= r:
	m = (l + r) // 2
	if check(m, 0) or check(m, 1):
		r = m - 1
		ans = m
	else:
		l = m + 1
print(ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
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
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')

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))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

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 power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

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

def possible(a, x, pos, k):
	curr = 0
	cnt = 0
	for i in range(0, len(a)):
		if curr == pos:
			if a[i] <= x:
				cnt += 1
				curr = 1 - curr
				continue
			else:
				continue
		else:
			cnt += 1
			curr = 1 - curr
			continue
	if cnt >= k:
		return True
	else:
		return False

def solve():
	(n, k) = sep()
	a = lis()
	(l, h) = (min(a), max(a))
	while l < h:
		mid = (l + h) // 2
		if possible(a, mid, 0, k) or possible(a, mid, 1, k):
			h = mid
		else:
			l = mid + 1
	print(l)
testcase(1)


def check(m, f, l1, k):
	cnt = 0
	for i in range(len(l1)):
		if l1[i] <= m or cnt % 2 == f:
			cnt += 1
	if cnt >= k:
		ans = 1
	else:
		ans = 0
	return ans
(n, k) = map(int, input().split())
l1 = list(map(int, input().split()))
l = 1
h = 1000000000.0 + 7
while l < h:
	m = int((l + h) // 2)
	if check(m, 0, l1, k) == 1 or check(m, 1, l1, k) == 1:
		h = m
	else:
		l = m + 1
print(l)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = 10 ** 9
while r - l != 1:
	m = (l + r) // 2
	ind = 0
	cnt = 0
	while ind < n:
		if a[ind] <= m and (not (k % 2 == 0 and ind == n - 1)):
			cnt += 1
			ind += 2
		else:
			ind += 1
	ind = 1
	cnt2 = 0
	while ind < n:
		if a[ind] <= m and (not (k % 2 == 1 and ind == n - 1)):
			cnt2 += 1
			ind += 2
		else:
			ind += 1
	if cnt >= (k + 1) // 2 or cnt2 >= k // 2:
		r = m
	else:
		l = m
print(r)


def isvalid0(x, num):
	count = 0
	curr = 0
	for i in range(n):
		if curr % 2 == 0:
			if li[i] <= x:
				count += 1
				curr ^= 1
		else:
			curr ^= 1
			count += 1
	if count >= num:
		return 1
	return 0

def isvalid1(x, num):
	count = 0
	curr = 0
	for i in range(n):
		if curr % 2 == 1:
			if li[i] <= x:
				count += 1
				curr ^= 1
		else:
			curr ^= 1
			count += 1
	if count >= num:
		return 1
	return 0

def binary_search(low, high):
	while low < high:
		mid = (low + high) // 2
		if isvalid0(mid, k) or isvalid1(mid, k):
			high = mid
		else:
			low = mid + 1
	return low
l = input().split()
n = int(l[0])
k = int(l[1])
l = input().split()
li = [int(i) for i in l]
print(binary_search(1, 10 ** 9))


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


(n, k) = map(int, input().split())
(*arr,) = map(int, input().split())
lo = 0
hi = max(arr)

def possible(arr, k, mid):
	odd_cnt = 0
	even_cnt = 0
	for v in arr:
		if v <= mid:
			(even_cnt, odd_cnt) = (max(odd_cnt + 1, even_cnt), max(even_cnt + 1, odd_cnt))
		else:
			odd_cnt = max(odd_cnt, even_cnt + 1)
	return max(even_cnt, odd_cnt) >= k
while lo < hi:
	mid = (lo + hi) // 2
	if possible(arr, k, mid):
		hi = mid
	else:
		lo = mid + 1
print(lo)


import sys
import math
input = sys.stdin.readline
(a, b) = list(map(int, input().split()))
n = list(map(int, input().split()))
best = 99999999999
fff = [0, 1]
for zzz in fff:
	x = max(n) // 2
	last_x = 0
	if zzz == 0:
		k = math.ceil(b / 2)
	else:
		k = math.floor(b / 2)
	counter = 0
	while True:
		test = []
		last = -999
		corr = 0
		if b % 2 == 1 and zzz == 1:
			corr = 1
		if b % 2 == 0 and zzz == 0:
			corr = 1
		for i in range(zzz, len(n) - corr):
			if n[i] <= x and i > last + 1:
				test.append(n[i])
				last = i
		if len(test) >= k and abs(x - last_x) <= 1:
			break
		if len(test) >= k:
			(x, last_x) = (x - max(1, math.ceil(abs(x - last_x) / 2)), x)
		else:
			(x, last_x) = (x + max(1, math.ceil(abs(x - last_x) / 2)), x)
		counter += 1
	best = min(best, max(test))
print(best)


import sys
from fractions import gcd
from math import ceil, sqrt, sin, pi, tan
from collections import defaultdict
read = sys.stdin.buffer.readline
import heapq
mi = lambda : map(int, read().split())
li = lambda : list(mi())
cin = lambda : int(read())
(n, k) = mi()
a = li()

def check(x, tag):
	ans = 0
	for i in range(n):
		if tag:
			if a[i] <= x:
				ans += 1
				tag = 1 ^ tag
		else:
			ans += 1
			tag ^= 1
	return ans >= k

def bs(l, h):
	while l < h:
		mid = (l + h) // 2
		if check(mid, 0) or check(mid, 1):
			h = mid
		else:
			l = mid + 1
	return l
print(int(bs(1, 1000000000.0)))


import sys
input = lambda : sys.stdin.buffer.readline().rstrip()
(n, k) = map(int, input().split())
a = list(map(int, input().split()))

def z(s, m):
	c = 0
	for i in range(n):
		if s or a[i] <= m:
			s ^= 1
			c += 1
		if c >= k:
			break
	return c >= k
q = 1
w = max(a)
while q < w:
	m = (q + w) // 2
	if z(0, m) or z(1, m):
		w = m
	else:
		q = m + 1
print(q)


import sys
import math
from decimal import *

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

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

def ILS():
	return list(map(str, sys.stdin.readline().strip().split()))

def echeck(x, l, k):
	cnt = 1
	cross = 0
	for p in l:
		if cnt % 2 != 0:
			cnt += 1
			continue
		elif p <= x:
			cnt += 1
			continue
		else:
			cross += 1
		if cross > k:
			return False
	if cross > k:
		return False
	return True

def ocheck(x, l, k):
	cnt = 1
	cross = 0
	for p in l:
		if cnt % 2 == 0:
			cnt += 1
			continue
		elif p <= x:
			cnt += 1
			continue
		else:
			cross += 1
		if cross > k:
			return False
	if cross > k:
		return False
	return True

def solve():
	(n, kk) = IL()
	k = n - kk
	l = IL()
	sl = l.copy()
	sl.sort()
	st = 0
	en = len(sl)
	while st < en - 1:
		mid = (st + en) // 2
		pos = echeck(sl[mid], l, k) or ocheck(sl[mid], l, k)
		if pos:
			en = mid
		else:
			st = mid
	if echeck(sl[st], l, k) or ocheck(sl[st], l, k):
		print(sl[st])
	else:
		print(sl[en])
solve()


import sys
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
from collections import defaultdict as df
import copy
(n, k) = RI()
l = RI()
if n == 2:
	if k == 2:
		print(min(l[0], l[1]))
elif k == n:
	even = 0
	odd = 0
	for i in range(n):
		if i % 2 == 0:
			even = max(even, l[i])
		else:
			odd = max(odd, l[i])
	print(min(even, odd))
else:
	mini = min(l)
	maxo = max(l)
	start = mini
	end = maxo
	while start <= end:
		mid = (start + end) // 2
		even = 0
		i = k
		j = 0
		parity = 0
		while j < n and i > 0:
			if parity == 0:
				if l[j] <= mid:
					i -= 1
					parity = 1
			else:
				i -= 1
				parity = 0
			j += 1
		if i == 0:
			even = 1
		odd = 0
		i = k
		j = 0
		parity = 1
		while j < n and i > 0:
			if parity == 0:
				if l[j] <= mid:
					i -= 1
					parity = 1
			else:
				i -= 1
				parity = 0
			j += 1
		if i == 0:
			odd = 1
		if odd == 1 or even == 1:
			end = mid - 1
		else:
			start = mid + 1
	print(end + 1)


(n, k) = map(int, input().split())
a = list(map(int, input().strip().split()))
l = 0
r = 10 ** 9
while r - l != 1:
	mid = (l + r) // 2
	id = 0
	even_cnt = 0
	while id < n:
		if a[id] <= mid and (not (k % 2 == 0 and id == n - 1)):
			even_cnt += 1
			id += 2
		else:
			id += 1
	id = 1
	odd_cnt = 0
	while id < n:
		if a[id] <= mid and (not (k % 2 == 1 and id == n - 1)):
			odd_cnt += 1
			id += 2
		else:
			id += 1
	if even_cnt >= (k + 1) // 2 or odd_cnt >= k // 2:
		r = mid
	else:
		l = mid
print(r)


def ss_length(arr, x, k, oe):
	l = 0
	for i in range(len(arr)):
		if oe:
			if arr[i] <= x:
				l += 1
				oe ^= 1
		else:
			l += 1
			oe ^= 1
	return l >= k

def bin_search(arr, li, hi, k):
	if li >= hi:
		return li
	mi = (li + hi) // 2
	ss_len_check = ss_length(arr, mi, k, 0) or ss_length(arr, mi, k, 1)
	if ss_len_check:
		return bin_search(arr, li, mi, k)
	else:
		return bin_search(arr, mi + 1, hi, k)
(n, k) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
ans = bin_search(arr, 1, int(1000000000.0), k)
print(ans)


import sys, math, os
from io import BytesIO, IOBase
from collections import defaultdict as dd, deque, Counter

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

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write('\n'.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = float('inf')
mod = 998244353
(n, k) = mdata()
a = mdata()
a1 = sorted(a)
l = 0
r = n - 1
m = INF
while l <= r:
	mid = (l + r) // 2
	t = a1[mid]
	ans1 = 0
	ans2 = 0
	d = []
	for i in range(n):
		if ans1 % 2 == 1:
			ans1 += 1
		elif a[i] <= t:
			ans1 += 1
		if ans2 % 2 == 0:
			ans2 += 1
		elif a[i] <= t:
			ans2 += 1
	if ans1 >= k or ans2 >= k:
		r = mid - 1
		m = min(m, t)
	else:
		l = mid + 1
out(m)


(n, k) = map(int, input().split())
ls = list(map(int, input().split()))
lo = 1
hi = max(ls)

def solve(num):
	ln = 0
	for i in range(n):
		if ln % 2:
			ln += 1
		elif ls[i] <= num:
			ln += 1
		if ln == k:
			return 1
	ln = 0
	for i in range(n):
		if ln % 2 == 0:
			ln += 1
		elif ls[i] <= num:
			ln += 1
		if ln == k:
			return 1
	return 0
res = 1
while lo <= hi:
	mid = (lo + hi) // 2
	if solve(mid):
		res = mid
		hi = mid - 1
	else:
		lo = mid + 1
print(res)


def check(mid, cur):
	ans = 0
	for i in range(n):
		if cur:
			ans += 1
			cur ^= 1
		elif lis[i] <= mid:
			cur ^= 1
			ans += 1
	return ans >= k
(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
l = 0
r = 100000000000000
while l <= r:
	mid = l + (r - l) // 2
	if check(mid, 0) or check(mid, 1):
		r = mid - 1
	else:
		l = mid + 1
print(l)


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
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')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

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

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def GP(it):
	return [(ch, len(list(g))) for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

def f(x, s, e, k):
	i = s
	c = 0
	while i < e:
		if a[i] <= x:
			c += 1
			i += 2
		else:
			i += 1
	return c >= k
t = 1
for i in range(t):
	(n, k) = RL()
	a = RLL()
	if k & 1:
		k = k // 2
		l = 1
		r = 10 ** 9
		while l < r:
			mid = (l + r) // 2
			if f(mid, 1, n - 1, k) or f(mid, 0, n, k + 1):
				r = mid
			else:
				l = mid + 1
		ans = l
	else:
		k //= 2
		l = 1
		r = 10 ** 9
		while l < r:
			mid = (l + r) // 2
			if f(mid, 0, n - 1, k) or f(mid, 1, n, k):
				r = mid
			else:
				l = mid + 1
		ans = l
	print(ans)


from collections import *
import math

def main():
	(N, K) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	print(search(N, K, arr))

def search(N, K, arr):
	lo = 0
	hi = N - 1
	sarr = sorted(arr)
	while lo < hi:
		mid = (lo + hi) // 2
		if works(sarr[mid], arr, K):
			hi = mid
		else:
			lo = mid + 1
	return sarr[lo]

def works(x, arr, K):
	good = False
	for swt in range(2):
		ct1 = 0
		ct2 = 0
		for idx in range(len(arr)):
			if swt == 0:
				ct1 += 1
				swt = 1
			elif arr[idx] <= x:
				ct2 += 1
				swt = 0
		good = good or ct1 + ct2 >= K
	return good
main()


import sys
import math
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())
(n, k) = invr()
ara = inara()
hi = int(1000000000.0)
lo = 0
ans = hi

def possible(x):
	curr = 0
	for i in range(n):
		if ara[i] <= x:
			curr += 1
		elif curr % 2 == 0:
			curr += 1
	if curr >= k:
		return True
	curr = 0
	for i in range(n):
		if ara[i] <= x:
			curr += 1
		elif curr % 2:
			curr += 1
	return curr >= k
while hi >= lo:
	mid = (hi + lo) // 2
	if possible(mid):
		ans = mid
		hi = mid - 1
	else:
		lo = mid + 1
print(ans)


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inpt():
	return [int(k) for k in input().split()]

def check(x, s, n, ar, k):
	ans = 0
	for i in range(n):
		if s == 0:
			ans += 1
			s ^= 1
		elif ar[i] <= x:
			ans += 1
			s ^= 1
	return ans >= k

def main():
	(n, k) = map(int, input().split())
	ar = inpt()
	(l, h) = (1, 10 ** 9)
	while l < h:
		mid = (l + h) // 2
		if check(mid, 0, n, ar, k) or check(mid, 1, n, ar, k):
			h = mid
		else:
			l = mid + 1
	print(l)
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')
main()


def find(arr, x, start, k, n):
	done = start
	curr = 0
	for i in range(start, n):
		if curr == 0:
			if arr[i] <= x:
				done += 1
				curr = 1 - curr
		else:
			done += 1
			curr = 1 - curr
	if done >= k:
		return True
	else:
		return False

def binarysearch(arr, n, k):
	start = 1
	end = 1000000000
	last = 0
	while start <= end:
		mid = (start + end) // 2
		if find(arr, mid, 0, k, n) or find(arr, mid, 1, k, n):
			last = mid
			end = mid - 1
		else:
			start = mid + 1
	return last

def help():
	(n, k) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	ans = binarysearch(arr, n, k)
	print(ans)
help()


import itertools

def brute(arr, k):
	resultSubseq = []
	result = float('inf')
	N = len(arr)
	for combo in itertools.combinations(arr, k):
		subseq = list(combo)
		subseq1 = [subseq[i] for i in range(0, len(subseq), 2)]
		subseq2 = [subseq[i] for i in range(1, len(subseq), 2)]
		cand1 = max(subseq1)
		cand2 = max(subseq2)
		pickedSubseq = []
		if cand1 < cand2:
			cost = cand1
			pickedSubseq = subseq1
		else:
			cost = cand2
			pickedSubseq = subseq2
		if cost <= result:
			result = cost
			resultSubseq = subseq
	return (result, resultSubseq)

def isPossibleCost(arr, k, cost):
	numAtEvens = 0
	numAtOdds = 0
	for num in arr:
		if num <= cost:
			numAtEvens += 1
			numAtOdds += 1
		else:
			if numAtEvens % 2 == 0:
				numAtEvens += 1
			if numAtOdds % 2 == 1:
				numAtOdds += 1
		if numAtEvens >= k or numAtOdds >= k:
			return True
	return False

def soln(arr, k):
	(left, right) = (min(arr), max(arr))
	result = 0
	while left <= right:
		mid = (left + right) // 2
		if isPossibleCost(arr, k, mid):
			result = mid
			right = mid - 1
		else:
			left = mid + 1
	return result

def main():
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	result = soln(arr, k)
	print(result)

def test():
	arr = [1, 3, 8, 9]
	k = 4
	(b, picked) = brute(arr, k)
	f = soln(arr, k)
	print(b, f)
	print(picked)

def randomTest():
	import random
	t = 100
	for i in range(1, t + 1):
		n = random.randint(2, 10)
		k = random.randint(2, n)
		arr = [random.randint(1, 10) for _ in range(n)]
		print(i, k, arr)
		(b, picked) = brute(arr, k)
		f = soln(arr, k)
		if b != f:
			print('Broken!')
			print(b, f)
			return

def stressTest():
	import random
	t = 100
	for i in range(1, t + 1):
		n = random.randint(2, 2 * 10 ** 5)
		k = random.randint(2, n)
		arr = [random.randint(1, 10 ** 9) for _ in range(n)]
		f = soln(arr, k)
		print(i, f)
main()


import sys
input = sys.stdin.readline

def done(parity, l, k, req):
	co = 0
	for i in range(len(l)):
		if parity == 0 and l[i] <= k:
			co += 1
			parity ^= 1
		elif parity == 1:
			parity ^= 1
			co += 1
	return co >= req
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
l = 1
r = 1000000000
ans = 9999999999999
while l < r:
	mid = (l + r) // 2
	if done(0, arr, mid, k) or done(1, arr, mid, k):
		r = mid
		ans = min(ans, mid)
	else:
		l = mid + 1
print(ans)


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

def checker(x, cur):
	ans = 0
	for i in range(n):
		if cur == 0:
			ans += 1
			cur = cur ^ 1
		elif arr[i] <= x:
			ans += 1
			cur ^= 1
	if ans >= k:
		return 1
	else:
		return 0
lo = 1
hi = 10 ** 9
while lo < hi:
	m = (lo + hi) // 2
	ans1 = checker(m, 0)
	ans2 = checker(m, 1)
	if ans1 == 1 or ans2 == 1:
		hi = m
	else:
		lo = m
	if hi - lo == 1:
		break
(ans1, ans2) = (checker(lo, 0), checker(lo, 1))
if ans1 == 1 or ans2 == 1:
	print(lo)
else:
	print(hi)


import sys
import math

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

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

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

def check(n, k, arr, x, oe):
	flag = True
	l = 0
	if oe == 1:
		flag = False
	for i in range(n):
		if flag:
			if arr[i] <= x:
				flag = False
				l += 1
		else:
			l += 1
			flag = True
	if l >= k:
		return True
	return False
(n, k) = get_ints()
arr = get_array()
tarr = sorted(arr)
l = 0
h = n - 1
while l < h:
	mid = (l + h) // 2
	if check(n, k, arr, tarr[mid], 1) or check(n, k, arr, tarr[mid], 0):
		h = mid
	else:
		l = mid + 1
print(tarr[h])


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
(n, k) = ip()
x = ip()
(l, r) = (0, max(x))
ans = 0
while l <= r:
	mid = (l + r) // 2
	flag = 0
	for start in [0, 1]:
		ct = 0
		alt = start
		for i in x:
			if not alt or i <= mid:
				ct += 1
				alt = not alt
		if ct >= k:
			flag = 1
	if flag:
		ans = mid
		r = mid - 1
	else:
		l = mid + 1
print(ans)


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

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 Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def solve(no):
	if k % 2 == 0:
		need = k // 2
		s = set()
		flag = False
		for i in range(len(a)):
			if i - 1 not in s and a[i] <= no:
				s.add(i)
			if len(s) == need:
				flag = True
				break
		if flag:
			flag = False
			tflag = True
			chose = 0
			for i in range(len(a)):
				if tflag:
					if i not in s:
						tflag = False
						chose += 1
				if i in s:
					tflag = True
				if chose == need:
					flag = True
					break
			if flag:
				return True
		need = k // 2
		s = set()
		flag = False
		for i in range(1, len(a)):
			if i - 1 not in s and a[i] <= no:
				s.add(i)
			if len(s) == need:
				flag = True
				break
		if flag:
			flag = False
			tflag = True
			chose = 0
			for i in range(len(a)):
				if tflag:
					if i not in s:
						tflag = False
						chose += 1
				if i in s:
					tflag = True
				if chose == need:
					flag = True
					break
			if flag:
				return True
		return False
	else:
		need1 = k // 2
		need2 = ceil(k / 2)
		s = set()
		flag = False
		for i in range(len(a)):
			if i - 1 not in s and a[i] <= no:
				s.add(i)
			if len(s) == need1:
				flag = True
				break
		if flag:
			flag = False
			tflag = True
			chose = 0
			for i in range(len(a)):
				if tflag:
					if i not in s:
						tflag = False
						chose += 1
				if i in s:
					tflag = True
				if chose == need2:
					flag = True
					break
			if flag:
				return True
		need1 = k // 2
		need2 = ceil(k / 2)
		s = set()
		flag = False
		for i in range(1, len(a)):
			if i - 1 not in s and a[i] <= no:
				s.add(i)
			if len(s) == need1:
				flag = True
				break
		if flag:
			flag = False
			tflag = True
			chose = 0
			for i in range(len(a)):
				if tflag:
					if i not in s:
						tflag = False
						chose += 1
				if i in s:
					tflag = True
				if chose == need2:
					flag = True
					break
			if flag:
				return True
		need2 = k // 2
		need1 = ceil(k / 2)
		s = set()
		flag = False
		for i in range(len(a)):
			if i - 1 not in s and a[i] <= no:
				s.add(i)
			if len(s) == need1:
				flag = True
				break
		if flag:
			flag = False
			tflag = True
			chose = 0
			for i in range(len(a)):
				if tflag:
					if i not in s:
						tflag = False
						chose += 1
				if i in s:
					tflag = True
				if chose == need2:
					flag = True
					break
			if flag:
				return True
		need2 = k // 2
		need1 = ceil(k / 2)
		s = set()
		flag = False
		for i in range(1, len(a)):
			if i - 1 not in s and a[i] <= no:
				s.add(i)
			if len(s) == need1:
				flag = True
				break
		if flag:
			flag = False
			tflag = True
			chose = 0
			for i in range(len(a)):
				if tflag:
					if i not in s:
						tflag = False
						chose += 1
				if i in s:
					tflag = True
				if chose == need2:
					flag = True
					break
			if flag:
				return True
		return False
(n, k) = Ri()
a = Ri()
(l, r) = (1, 10 ** 9)
maxx = 10 ** 9
while l <= r:
	mid = (l + r) // 2
	if solve(mid):
		r = mid - 1
		maxx = min(maxx, mid)
	else:
		l = mid + 1
print(maxx)


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


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
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 = 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) = sp()
arr = l()
temp = arr[:]
temp.sort()
if k <= 2:
	out(temp[0])
	exit()
if k == 3:
	if 0 < arr.index(temp[0]) < n - 1:
		out(temp[0])
		exit()
	out(temp[1])
	exit()
(low, high) = (0, n - 1)
half = temp[-1]
while low <= high:
	mid = low + high >> 1
	(index1, index2) = (0, 0)
	for i in range(n):
		if arr[i] <= temp[mid] or index1 & 1:
			index1 += 1
		if arr[i] <= temp[mid] or not index2 & 1:
			index2 += 1
	if index1 >= k or index2 >= k:
		half = min(half, temp[mid])
		high = mid - 1
	else:
		low = mid + 1
out(half)


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

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))
from math import sqrt, floor, factorial, gcd, log
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))

def solve():
	(n, k) = read()
	arr = read()

	def Odd_seq(x):
		c = 1
		for i in range(n):
			if c % 2:
				if arr[i] <= x:
					c += 1
			else:
				c += 1
		return c - 1 >= k

	def Even_seq(x):
		c = 1
		for i in range(n):
			if c % 2 == 0:
				if arr[i] <= x:
					c += 1
			else:
				c += 1
		return c - 1 >= k
	(lo, hi) = (1, 10 ** 9)
	last = 0
	while lo <= hi:
		mid = (lo + hi) // 2
		res = Odd_seq(mid) or Even_seq(mid)
		if res:
			last = mid
			hi = mid - 1
		else:
			lo = mid + 1
	print(last)
solve()


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = 10 ** 9
while l + 1 < r:
	try1 = (l + r) // 2
	count = 0
	tally = 0
	firstzero = 0
	if k % 2 == 1:
		firstzero = 1
	for i in range(n):
		if a[i] > try1:
			firstzero = i
			break
		if i == n - 1:
			firstzero = n
	for i in range(n):
		if a[n - 1 - i] > try1:
			lastzero = i
			break
		if i == n - 1:
			lastzero = i
	for i in range(firstzero, n - lastzero):
		if a[i] <= try1:
			count += 1
		else:
			if count % 2 == 0:
				tally += count // 2
			else:
				tally += 1 + count // 2
			count = 0
	if firstzero == n:
		tally = n // 2
	else:
		if k % 2 == 1 and firstzero % 2 == 1 and (lastzero % 2 == 1):
			tally += 1
		if k % 2 == 0 and firstzero % 2 == 1 and (lastzero % 2 == 1):
			firstzero = max(firstzero - 1, 0)
		if k % 2 == 1:
			firstzero = max(firstzero - 1, 0)
			lastzero = max(lastzero - 1, 0)
		if firstzero % 2 == 0:
			tally += firstzero // 2
		else:
			tally += 1 + firstzero // 2
		if lastzero % 2 == 0:
			tally += lastzero // 2
		else:
			tally += 1 + lastzero // 2
	if tally >= k // 2:
		r = try1
	else:
		l = try1
try1 = l
tally = 0
firstzero = 0
count = 0
for i in range(n):
	if a[i] > try1:
		firstzero = i
		break
	if i == n - 1:
		firstzero = n
for i in range(n):
	if a[n - 1 - i] > try1:
		lastzero = i
		break
	if i == n - 1:
		lastzero = i
for i in range(firstzero, n - lastzero):
	if a[i] <= try1:
		count += 1
	else:
		if count % 2 == 0:
			tally += count // 2
		else:
			tally += 1 + count // 2
		count = 0
if firstzero == n:
	tally = n // 2
else:
	if k % 2 == 1 and firstzero % 2 == 1 and (lastzero % 2 == 1):
		tally += 1
	if k % 2 == 1:
		firstzero = max(firstzero - 1, 0)
		lastzero = max(lastzero - 1, 0)
	if k % 2 == 0 and firstzero % 2 == 1 and (lastzero % 2 == 1):
		firstzero = max(firstzero - 1, 0)
	if firstzero % 2 == 0:
		tally += firstzero // 2
	else:
		tally += 1 + firstzero // 2
	if lastzero % 2 == 0:
		tally += lastzero // 2
	else:
		tally += 1 + lastzero // 2
if tally >= k // 2:
	print(l)
else:
	print(r)


from sys import stdin
(n, k) = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
if k % 2 == 0:
	lo = min(arr)
	hi = max(arr)
	while lo <= hi:
		fl = 0
		mid = (lo + hi) // 2
		co = co1 = 0
		fll = 0
		fll1 = 1
		aa = 0
		for (ind, val) in enumerate(arr):
			vis = 0
			if val <= mid and (not fll):
				co += 1
				vis += 1
				if ind == 0 or ind == n - 1:
					aa += 0.5
			if val <= mid and (not fll1):
				co1 += 1
				vis += 2
			if vis == 0:
				fll = fll1 = 0
			elif vis == 2:
				fll = 0
				fll1 = 1
			elif vis == 1:
				fll = 1
				fll1 = 0
			elif vis == 3:
				fll = fll1 = 1
		if co >= k // 2 + int(aa) or co1 >= k // 2:
			hi = mid - 1
		else:
			fl = 1
			lo = mid + 1
	print(mid + fl)
else:
	lo = min(arr)
	hi = max(arr)
	while lo <= hi:
		fl = 0
		mid = (lo + hi) // 2
		co = co1 = 0
		fll = 0
		fll1 = 1
		aa = 0
		bb = 0
		for (ind, val) in enumerate(arr):
			vis = 0
			if val <= mid and (not fll):
				co += 1
				vis += 1
				if ind == n - 1 or ind == 0:
					aa = 1
			if val <= mid and (not fll1):
				co1 += 1
				vis += 2
				if ind == n - 1:
					bb = 1
			if vis == 0:
				fll = fll1 = 0
			if vis == 2:
				fll = 0
				fll1 = 1
			elif vis == 1:
				fll = 1
				fll1 = 0
			elif vis == 3:
				fll = fll1 = 1
		if co >= k // 2 + aa or co1 >= k // 2 + bb:
			hi = mid - 1
		else:
			fl = 1
			lo = mid + 1
	print(mid + fl)


(n, k) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]

def check(x, p):
	ans = 0
	for i in range(len(arr)):
		if not p:
			ans += 1
			p ^= 1
		elif arr[i] <= x:
			ans += 1
			p ^= 1
	return ans >= k
l = 1
r = 10 ** 9
res = 0
while l <= r:
	mid = l + (r - l) // 2
	if check(mid, 0) or check(mid, 1):
		res = mid
		r = mid - 1
	else:
		l = mid + 1
print(res)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq 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 tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def possible(x):
	elements = 0
	i = 0
	while i < n and elements < k:
		if elements % 2:
			elements += 1
		elif a[i] <= x:
			elements += 1
		i += 1
	if elements == k:
		return True
	elements = 0
	i = 0
	while i < n and elements < k:
		if not elements % 2:
			elements += 1
		elif a[i] <= x:
			elements += 1
		i += 1
	return elements == k
(n, k) = value()
a = array()
low = min(a)
high = max(a)
while low <= high:
	mid = (low + high) // 2
	if possible(mid):
		ans = mid
		high = mid - 1
	else:
		low = mid + 1
print(ans)


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

def check(mid, x):
	count = 0
	for i in a:
		if i <= mid or x % 2 == 1:
			count += 1
			x ^= 1
	return count >= k
lo = 1
hi = max(a)
while lo < hi:
	mid = (lo + hi) // 2
	if check(mid, 0) or check(mid, 1):
		hi = mid
	else:
		lo = mid + 1
print(lo)


def solve(mid, s, arr):
	lens = 0
	for i in range(len(arr)):
		if s == 0:
			lens += 1
			s = s ^ 1
		elif arr[i] <= mid:
			lens += 1
			s = s ^ 1
	return lens >= k
(n, k) = map(int, input().split())
arr = list(map(int, input().strip().split()))[:n]
low = 0
high = 10 ** 9
while low < high:
	mid = low + (high - low) // 2
	if solve(mid, 0, arr) or solve(mid, 1, arr):
		high = mid
	else:
		low = mid + 1
print(low)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(l, r) = (1, 2 * 10 ** 9)
odd = (k + 1) // 2
even = k // 2
ans = r
while l < r:
	mid = l + r >> 1
	ok = 0
	(tempk, i) = (odd, 0)
	nn = n
	nn -= k % 2 == 0
	while i < nn:
		if a[i] <= mid:
			tempk -= 1
			i += 1
		i += 1
	ok |= tempk <= 0
	(tempk, i, nn) = (even, 1, n)
	nn -= k & 1
	while i < nn:
		if a[i] <= mid:
			tempk -= 1
			i += 1
		i += 1
	ok |= tempk <= 0
	if ok:
		r = mid
		ans = min(ans, mid)
	else:
		l = mid + 1
print(ans)


import os
import sys
from io import BytesIO, IOBase

def is_possible(mid, p, arr, n, k):
	cnt = 0
	if p == 1:
		for i in range(1, n + 1):
			if cnt & 1 == 0:
				if arr[i] <= mid:
					cnt += 1
			else:
				cnt += 1
		return cnt >= k
	else:
		for i in range(1, n + 1):
			if cnt & 1 == 0:
				cnt += 1
			elif arr[i] <= mid:
				cnt += 1
		return cnt >= k

def go(lo, hi, arr, n, k):
	res = hi
	while lo <= hi:
		mid = lo + (hi - lo) // 2
		if is_possible(mid, 1, arr, n, k) or is_possible(mid, 2, arr, n, k):
			res = mid
			hi = mid - 1
		else:
			lo = mid + 1
	return res

def solution(arr, k, n):
	res = go(1, int(1000000000.0), arr, n, k)
	write(res)

def main():
	(n, k) = r_array()
	arr = [0] + r_array()
	solution(arr, k, n)
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

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

def r_int():
	return int(input())
main()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
(n, k) = map(int, input().split())
arr = [int(x) for x in input().split()]

def check(mid, arr, k, parity):
	ans = 0
	for item in arr:
		if ans + 1 & 1 == parity:
			if item <= mid:
				ans += 1
		else:
			ans += 1
	return ans >= k

def bsearch(arr, k):
	(low, high) = (min(arr), max(arr))
	while low < high:
		mid = (low + high) // 2
		if check(mid, arr, k, 0) or check(mid, arr, k, 1):
			high = mid
		else:
			low = mid + 1
	return low
print(bsearch(arr, k))


from sys import maxsize
(n, k) = map(int, input().split())
ls = list(map(int, input().split()))
ar = sorted(ls)
mx = max(ls)
low = 0
high = n - 1
ans = maxsize
while low <= high:
	mid = (low + high) // 2
	f = False
	for turn in range(2):
		curr_t = turn
		took = 0
		for i in range(n):
			if not curr_t or ls[i] <= ar[mid]:
				took += 1
				curr_t = 1 - curr_t
		if took >= k:
			f = True
			break
	if f:
		ans = ar[mid]
		high = mid - 1
	else:
		low = mid + 1
print(ans)


def testing():
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	min_ = 1
	max_ = 10 ** 9
	while min_ < max_:
		target = (min_ + max_) // 2
		skip = 0
		count = 0
		for i in range(len(arr)):
			if skip or arr[i] <= target:
				count += 1
				skip = 1 - skip
		if count >= k:
			max_ = target
			continue
		skip = 1
		count = 0
		for i in range(len(arr)):
			if skip or arr[i] <= target:
				count += 1
				skip = 1 - skip
		if count >= k:
			max_ = target
		else:
			min_ = target + 1
	return max_
print(testing())


import sys
input = sys.stdin.buffer.readline
import os
from math import *

def ischeck(val, z):
	s = 0
	for i in range(0, n):
		if s % 2 == z:
			s += 1
		elif arr[i] <= val:
			s += 1
	return s >= k

def search(l, h):
	ans = h
	while l <= h:
		mid = (l + h) // 2
		if ischeck(mid, 1) or ischeck(mid, 0):
			ans = mid
			h = mid - 1
		else:
			l = mid + 1
	return ans
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
print(search(1, max(arr)))


from sys import stdin
input = stdin.readline
(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
min_ = 1
max_ = 10 ** 9

def works(arr, k, target, skip):
	count = 0
	for i in range(len(arr)):
		if skip or arr[i] <= target:
			count += 1
			skip = 1 - skip
	return count >= k
while min_ < max_:
	target = (min_ + max_) // 2
	if works(arr, k, target, 0) or works(arr, k, target, 1):
		max_ = target
	else:
		min_ = target + 1
print(max_)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

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))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

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 fsep():
	return map(float, inp().split())

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

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

def pow(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
from functools import reduce

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 gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

def YES():
	print('YES')

def NO():
	print('NO')

def Yes():
	print('Yes')

def No():
	print('No')
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		self.num_sets -= 1
		self.parent[a] = b
		self.size[b] += self.size[a]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

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

def solve():

	def search():
		l = 0
		r = 10 ** 10
		for i in range(100):
			if isvalid(l):
				return l
			if l == r:
				return l
			m = (l + r) // 2
			if isvalid(m) and (not isvalid(m - 1)):
				return m
			if isvalid(m):
				r = m + 1
			else:
				l = m
		return m
	(n, k) = sep()
	ar = lis()

	def isvalid(v):
		o = 1
		r = 0
		for i in range(n):
			if o == 1:
				if ar[i] <= v:
					r += 1
					o = 0
			else:
				r += 1
				o = 1
		if r >= k:
			return 1
		e = 0
		r = 0
		for i in range(n):
			if e == 1:
				if ar[i] <= v:
					r += 1
					e = 0
			else:
				r += 1
				e = 1
		if r >= k:
			return 1
		return 0
	print(search())
solve()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
(n, k) = map(int, input().split())
arr = [int(x) for x in input().split()]
low = min(arr)
high = max(arr)

def check(mid):
	(subseq1, subseq2) = ([], [])
	for item in arr:
		if len(subseq1) + 1 & 1:
			if item <= mid:
				subseq1.append(item)
		else:
			subseq1.append(item)
	for item in arr:
		if len(subseq2) + 1 & 1:
			subseq2.append(item)
		elif item <= mid:
			subseq2.append(item)
	return len(subseq1) >= k or len(subseq2) >= k
while low < high:
	mid = (low + high) // 2
	if check(mid):
		high = mid
	else:
		low = mid + 1
print(low)


import sys
input = sys.stdin.readline

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

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

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

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 and n > 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 and n > 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(10000000.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')

def check(x, cur):
	ans = 0
	for i in range(n):
		if not cur:
			ans += 1
			cur ^= 1
		elif a[i] <= x:
			ans += 1
			cur ^= 1
	return ans >= k

def bin_search(lo, hi):
	while lo < hi:
		mid = (lo + hi) // 2
		if check(mid, 0) or check(mid, 1):
			hi = mid
		else:
			lo = mid + 1
	return lo
(n, k) = int_array()
a = int_array()
ans = bin_search(0, int(1000000000.0 + 1))
print(ans)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
left = 1
right = 1000000001
while abs(left - right) > 1:
	mid = (right + left) // 2
	k = 0
	f = False
	for i in range(n):
		if f:
			k += 1
			f = False
			continue
		if arr[i] <= mid:
			k += 1
			f = True
			continue
	if k >= m:
		right = mid
	else:
		left = mid
mid = left
k = 0
f = False
for i in range(n):
	if f:
		k += 1
		f = False
		continue
	if arr[i] <= mid:
		k += 1
		f = True
		continue
if k < m:
	ans = right
else:
	ans = left
k = 0
left = 1
right = 1000000001
while abs(left - right) > 1:
	mid = (right + left) // 2
	k = 0
	f = False
	k += 1
	for i in range(1, n):
		if f:
			k += 1
			f = False
			continue
		if arr[i] <= mid:
			k += 1
			f = True
			continue
	if k >= m:
		right = mid
	else:
		left = mid
mid = left
k = 0
f = False
k += 1
for i in range(1, n):
	if f:
		k += 1
		f = False
		continue
	if arr[i] <= mid:
		k += 1
		f = True
		continue
if k < m:
	ans = min(ans, right)
else:
	ans = min(ans, left)
print(ans)


production = True
import sys, math, collections

def input(input_format=0, multi=0):
	if multi > 0:
		return [input(input_format) for i in range(multi)]
	else:
		next_line = sys.stdin.readline()[:-1]
		if input_format >= 10:
			use_list = False
			input_format = int(str(input_format)[-1])
		else:
			use_list = True
		if input_format == 0:
			formatted_input = [next_line]
		elif input_format == 1:
			formatted_input = list(map(int, next_line.split()))
		elif input_format == 2:
			formatted_input = list(map(float, next_line.split()))
		elif input_format == 3:
			formatted_input = list(next_line)
		elif input_format == 4:
			formatted_input = list(map(int, list(next_line)))
		elif input_format == 5:
			formatted_input = next_line.split()
		else:
			formatted_input = [next_line]
		return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format=0, newline=True):
	formatted_output = ''
	if output_format == 0:
		formatted_output = str(output_line)
	elif output_format == 1:
		formatted_output = ' '.join(map(str, output_line))
	elif output_format == 2:
		formatted_output = '\n'.join(map(str, output_line))
	print(formatted_output, end='\n' if newline else '')

def log(*args):
	if not production:
		print('$$$', end='')
		print(*args)
enu = enumerate
ter = lambda a, b, c: b if a else c

def mapl(iterable, format=0):
	if format == 0:
		return list(map(int, iterable))
	elif format == 1:
		return list(map(str, iterable))
	elif format == 2:
		return list(map(list, iterable))

def make(a, k, b, t):
	skip = t
	y = 0
	for i in a:
		if skip:
			y += 1
			skip = 0
			continue
		if i <= b:
			skip = 1
			y += 1
	return y >= k

def check(a, k, b):
	return make(a, k, b, 1) or make(a, k, b, 0)

def bsearch(a, k, l, r):
	p = l + (r - l) // 2
	lm = check(a, k, p)
	rm = check(a, k, p + 1)
	log(l, r, p)
	if not lm and rm:
		return p + 1
	elif rm and lm:
		return bsearch(a, k, l, p)
	elif not rm and (not lm):
		return bsearch(a, k, p + 1, r)

def solve():
	(n, k) = input(1)
	a = input(1)
	m = bsearch(a, k, 0, 10 ** 9)
	out(m)
	return
solve()


def isValid(m, f):
	c = 0
	for i in range(n):
		if c % 2 == f or a[i] <= m:
			c += 1
		if c >= k:
			return True
	return False
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
h = max(a)
l = min(a)
ans = h
while l < h:
	m = (l + h) // 2
	if isValid(m, 0) or isValid(m, 1):
		ans = m
		h = m
	else:
		l = m + 1
print(ans)


import heapq

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

def print_list(l):
	print(' '.join(map(str, l)))
(n, k) = read_list()
a = read_list()

def check(m):
	count = 0
	i = 0
	t = k + 1 >> 1
	while i < n - 1 + (k & 1) and count < t:
		if a[i] <= m:
			count += 1
			i += 2
		else:
			i += 1
	if count == t:
		return True
	i = 1
	count = 0
	t = k >> 1
	while i < n - (k & 1) and count < t:
		if a[i] <= m:
			count += 1
			i += 2
		else:
			i += 1
	if count == t:
		return True
	return False
(l, r) = (min(a), max(a))
while l < r:
	m = l + r >> 1
	if check(m):
		r = m
	else:
		l = m + 1
print(l)


import logging, sys
logging.basicConfig(level=logging.INFO)

def check(mid, a, k, n):
	st = int(0)
	d = 1
	keep = st + 1
	while d < k and keep < n:
		d += 1
		if d % 2 == 1:
			keep += 1
		else:
			while keep < n and a[keep] > mid:
				keep += 1
			if keep == n:
				d -= 1
				break
			keep += 1
	if d == k:
		return True
	if a[0] <= mid:
		d = 1
		keep = st + 1
		while d < k and keep < n:
			d += 1
			if d % 2 == 0:
				keep += 1
			else:
				while keep < n and a[keep] > mid:
					keep += 1
				if keep == n:
					d -= 1
					break
				keep += 1
		if d == k:
			return True
	return False

def main():
	(n, k) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	l = 1
	r = int(1000000000.0)
	ans = -1
	while l <= r:
		mid = (l + r) // 2
		if check(mid, a, k, n):
			ans = mid
			r = mid - 1
		else:
			l = mid + 1
	print(ans)
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
main()


def check(num):
	count = 0
	flag = -1
	s = 0
	for i in range(n):
		if a[i] <= num:
			count += 1
			s += 1
		elif flag == -1:
			flag = s % 2
			count += 1
			s += 1
		elif (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)


(n, k) = map(int, input().split())
l = 0
r = 10 ** 9
a = list(map(int, input().split()))

def is_ok(num):
	length = 0
	for i in range(len(a)):
		if length % 2 == 0 and a[i] <= num:
			length += 1
		elif length % 2 == 1:
			length += 1
	if length >= k:
		return True
	length = 0
	for i in range(len(a)):
		if length % 2 == 1 and a[i] <= num:
			length += 1
		elif length % 2 == 0:
			length += 1
	if length >= k:
		return True
	return False
while r - l > 1:
	m = (r + l) // 2
	if is_ok(m):
		r = m
	else:
		l = m
print(r)


from sys import stdin, stdout
input = stdin.readline

def isValid(v, b, mid, k):
	sub = 0
	for x in v:
		if b == 0:
			sub += 1
			b = 1
		elif x <= mid:
			b = 0
			sub += 1
	return sub >= k

def solve(cs):
	x = input()
	(n, m) = list(map(int, x.split()))
	v = list(map(int, input().strip().split(' ')))
	lo = 1
	hi = 1000000000
	ans = -1
	while lo <= hi:
		mid = lo + hi >> 1
		if isValid(v, 0, mid, m) or isValid(v, 1, mid, m):
			hi = mid - 1
			ans = mid
		else:
			lo = mid + 1
	print(ans)
for tc in range(1):
	solve(tc + 1)


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

def check(x, cur):
	res = 0
	for i in range(n):
		if cur == 0:
			res += 1
			cur ^= 1
		elif lista[i] <= x:
			res += 1
			cur ^= 1
	if res >= k:
		return True
	else:
		return False

def buscabin(low, high):
	while low < high:
		meio = (low + high) // 2
		if check(meio, 0) or check(meio, 1):
			high = meio
		else:
			low = meio + 1
	return low
resposta = buscabin(0, 10 ** 9)
print(resposta)


import sys
input = sys.stdin.readline
import heapq
import copy
import math
import decimal

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

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

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

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

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

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = 1
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	start = {}

	def is_possible(a, target, start, k):
		if start == 1:
			req = k // 2
			if k % 2 == 0:
				last = len(a)
			else:
				last = len(a) - 1
		else:
			req = math.ceil(k / 2)
			if k % 2 == 0:
				last = len(a) - 1
			else:
				last = len(a)
		pre = -2
		for i in range(start, last):
			if a[i] <= target and i != pre + 1:
				pre = i
				req = req - 1
				if req <= 0:
					return 1
		return 0
	for test in range(tests):
		[n, k] = inlt()
		a = inlt()
		l = 0
		r = max(a)
		while r > l:
			mid = (l + r) // 2
			if is_possible(a, mid, 0, k) or is_possible(a, mid, 1, k):
				r = mid
			else:
				l = mid + 1
		print(r)
main()


def check(a, mid, t):
	l = 0
	for i in range(len(a)):
		if t:
			if l % 2 and a[i] <= mid:
				l += 1
			elif not l % 2:
				l += 1
		elif not l % 2 and a[i] <= mid:
			l += 1
		elif l % 2:
			l += 1
	return l

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	(lo, hi) = (min(a), max(a))
	mi = hi
	while lo <= hi:
		mid = (lo + hi) // 2
		e = max(check(a, mid, 0), check(a, mid, 1))
		if e >= k:
			(mi, hi) = (min(mid, mi), mid - 1)
		else:
			lo = mid + 1
	print(mi)
main()


import sys
from collections import deque
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))

def possible(x):
	L = [0] * n
	B = [-1] * n
	prev = deque(maxlen=2)
	for i in range(n):
		if a[i] > x:
			continue
		L[i] = 1
		B[i] = i
		for j in prev:
			if j + 1 == i:
				continue
			if 1 + L[j] >= L[i]:
				B[i] = B[j]
				L[i] = 1 + L[j]
		prev.append(i)
	for i in range(n):
		if B[i] == -1:
			continue
		length = L[i] * 2 - 1
		if B[i] >= 1:
			length += 1
		if i + 1 < n:
			length += 1
		if length >= k:
			return True
	return False
(lo, hi) = (0, max(a))
while lo + 1 < hi:
	mid = (lo + hi) // 2
	if possible(mid):
		hi = mid
	else:
		lo = mid
print(hi)


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

def check(minn, ans):
	array = [0]
	for i in a:
		if len(array) % 2 == 0:
			array.append(i)
		elif i <= minn:
			array.append(i)
	if len(array) - 1 >= ans:
		return True
	array = [0]
	for i in a:
		if len(array) % 2 == 1:
			array.append(i)
		elif i <= minn:
			array.append(i)
	if len(array) - 1 >= ans:
		return True
	return False
first = 0
last = len(a_sorted) - 1
while last > first:
	middle = (last + first) // 2
	if check(a_sorted[middle], k) == True:
		last = middle - 1
	else:
		first = middle + 1
if check(a_sorted[0], k) == True:
	print(a_sorted[0])
elif check(a_sorted[last], k) == True:
	print(a_sorted[last])
else:
	print(a_sorted[last + 1])


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
(n, k) = map(int, input().split())
a = list(map(int, input().split()))

def z(s, m):
	c = 0
	for i in range(n):
		if s or a[i] <= m:
			s ^= 1
			c += 1
	return c >= k
q = 1
w = max(a)
while q < w:
	m = (q + w) // 2
	if z(0, m) or z(1, m):
		w = m
	else:
		q = m + 1
print(q)


from sys import stdin
input = stdin.readline

def check(x, pos):
	length = 0
	for i in range(n):
		if pos:
			if a[i] <= x:
				length += 1
				pos ^= 1
		else:
			length += 1
			pos ^= 1
	if length >= k:
		return True
	else:
		return False

def answer():
	(l, h) = (0, 10 ** 9)
	ans = 0
	while l <= h:
		x = (l + h) // 2
		if check(x, 0) or check(x, 1):
			h = x - 1
		else:
			l = x + 1
			ans = l
	return ans
for T in range(1):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	print(answer())


def is_possible(a, value, is_odd, k):
	seq_len = 0
	looking_for_x = is_odd
	for el in a:
		if not looking_for_x or (looking_for_x and el <= value):
			seq_len += 1
			looking_for_x = not looking_for_x
	return seq_len >= k

def find_max(a, is_odd, k):
	current = 1
	count = max(a) + 1
	while count > 0:
		step = count // 2
		test = current + step
		if is_possible(a, test, is_odd, k):
			count = step
		else:
			current = test + 1
			count -= step + 1
	return current

def solve():
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	return min(find_max(a, 0, k), find_max(a, 1, k))

def main():
	t = 1
	for _ in range(t):
		print(solve())
main()


import sys
import heapq
pprint = lambda s: print(' '.join(map(str, s)))
input = lambda : sys.stdin.readline().strip()
ipnut = input
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
dp1 = []
dp2 = []
if k < 3:
	print(min(a))
	exit(0)
a = list(map(lambda x: (x[1], x[0]), enumerate(a)))
a.sort()
if k % 2 == 0:

	def f(m):
		used = [0] * (n + 1)
		for (v, i) in a[:m]:
			used[i] = 1
		used1 = used[:]
		used[0] = 0
		used1[-2] = 0
		counter = 0
		counter1 = 0
		for i in range(n):
			if used[i] and used[i + 1]:
				used[i + 1] = 0
				counter += 1
			elif used[i]:
				counter += 1
		for i in range(n):
			if used1[i] and used1[i + 1]:
				used1[i + 1] = 0
				counter1 += 1
			elif used1[i]:
				counter1 += 1
		return counter >= k // 2 or counter1 >= k // 2
else:

	def f(m):
		used = [0] * (n + 1)
		for (v, i) in a[:m]:
			used[i] = 1
		used1 = used[:]
		counter1 = 0
		counter2 = 0
		for i in range(1, n - 1):
			if used[i] and used[i + 1]:
				used[i + 1] = 0
				counter1 += 1
			elif used[i]:
				counter1 += 1
		for i in range(n):
			if used1[i] and used1[i + 1]:
				used1[i + 1] = 0
				counter2 += 1
			elif used1[i]:
				counter2 += 1
		return counter1 >= k // 2 or counter2 >= k // 2 + 1
used = [0] * (n + 2)
dlen = 0
ans = 0
l = 0
r = n
while r - l > 1:
	m = (r + l) // 2
	if f(m):
		r = m
	else:
		l = m
print(a[r - 1][0])


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	l = 0
	r = 1000000005
	while l < r - 1:
		mid = (l + r) // 2
		count = 0
		flag = a[0] <= mid
		if flag:
			count += 1
		for i in range(1, n):
			if flag:
				count += 1
				flag = False
			elif a[i] <= mid:
				count += 1
				flag = True
		if count >= k:
			r = mid
			continue
		flag = False
		count = 1
		for i in range(1, n):
			if flag:
				count += 1
				flag = False
			elif a[i] <= mid:
				count += 1
				flag = True
		if count >= k:
			r = mid
		else:
			l = mid
	print(r)
	return
main()


def check(M, x):
	if u[M][0] > x:
		return False
	cnt = 1
	if M < n - 1:
		cnt += 1
	if M > 0:
		cnt += 1
	i = M + 2
	while i < n:
		if u[i][0] <= x:
			cnt += 1
			if i < n - 1:
				cnt += 1
				i += 1
		i += 1
	i = M - 2
	while i >= 0:
		if u[i][0] <= x:
			cnt += 1
			if i > 0:
				cnt += 1
				i -= 1
		i -= 1
	return cnt >= k
(n, k) = map(int, input().split())
u = list(map(int, input().split()))
for i in range(n):
	u[i] = (u[i], i)
s = sorted(u)
s.reverse()
L = 0
R = n
while R - L > 1:
	M = (L + R) // 2
	if check(s[M][1], s[M][0]) or (s[M][1] > 0 and check(s[M][1] - 1, s[M][0])) or (s[M][1] < n - 1 and check(s[M][1] + 1, s[M][0])):
		L = M
	else:
		R = M
print(s[L][0])


from sys import stdin
input = stdin.readline
(N, K) = [int(x) for x in input().split()]
arr = list(map(int, input().split()))
sizes = [(K + 1) // 2, K // 2]
start = [0, 1]
(low, high, ans) = (1, 10 ** 9, 10 ** 9)
while low <= high:
	mid = (low + high) // 2
	v = []
	for i in range(0, N):
		if arr[i] <= mid:
			v.append(i)
	works = False
	for x in range(0, 2):
		lst = start[x] - 1
		ptr = 0
		bad = False
		for i in range(0, sizes[x]):
			while ptr < len(v) and v[ptr] <= lst:
				ptr += 1
			if ptr == len(v):
				bad = True
				break
			lst = v[ptr] + 1
		if lst == N and x == K % 2:
			bad = True
		if not bad:
			works = True
			break
	if works:
		ans = mid
		high = mid - 1
	else:
		low = mid + 1
print(ans)


import sys
import math as mt
input = sys.stdin.buffer.readline
t = 1

def check(x, p1, p2):
	(g1, g2) = (0, 0)
	for i in range(n):
		if p1 == -1:
			if l[i] <= x:
				g1 += 1
				p1 = 1
			p2 = -1
		else:
			g2 += 1
			p2 = 1
			p1 = -1
		i += 1
	return g1 + g2 >= k
for __ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	(le, ri) = (0, 2 * 10 ** 9)
	d = {}
	for i in l:
		d[i] = 1
	ans = 0
	while le < ri:
		mid = (le + ri) // 2
		if check(mid, -1, 1) or check(mid, 1, -1):
			if d.get(mid, -1) != -1:
				ans = mid
			ri = mid
		else:
			le = mid + 1
	print(ans)


import sys
import math
import collections
import heapq

def set_debug(debug_mode=False):
	if debug_mode:
		fin = open('input.txt', 'r')
		sys.stdin = fin

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

def check(a, m, chk, k):
	ct = 0
	for i in a:
		if i <= m or ct % 2 != chk:
			ct += 1
	if ct >= k:
		return True
	else:
		return False
t = 1
for ti in range(1, t + 1):
	(n, k) = int_input()
	A = int_input()
	l = 1
	h = 10 ** 9 + 1
	while l < h:
		m = (l + h) // 2
		if check(A, m, 0, k) or check(A, m, 1, k):
			h = m
		else:
			l = m + 1
	print(l)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
le = 0
re = 10 ** 9

def solve(val):
	i = 0
	j = 0
	for ii in range(n):
		if i % 2 == 1 and l[ii] <= val:
			i += 1
		elif i % 2 == 0:
			i += 1
		if j % 2 == 0 and l[ii] <= val:
			j += 1
		elif j % 2:
			j += 1
	if i >= m or j >= m:
		return True
	return False
while re - le >= 1:
	mid = le + (re - le) // 2
	if solve(mid):
		ans = mid
		re = mid
	else:
		le = mid + 1
print(ans)


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

def check(m, ind):
	c = 0
	for i in arr:
		if i <= m or c % 2 != ind:
			c += 1
	return c >= k
(l, h) = (1, 10 ** 9)
while l < h:
	m = (l + h) // 2
	if check(m, 0) or check(m, 1):
		h = m
	else:
		l = m + 1
print(l)


import sys
import math

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

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

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

def SI():
	return sys.stdin.readline().strip()
(n, k) = MI()
a = LI()

def check(mid, isEven):
	ans = 0
	for i in range(n):
		if isEven or a[i] <= mid:
			ans += 1
			isEven = 1 - isEven
	return ans >= k
l = 0
r = max(a)
ans = r
while l < r:
	mid = (l + r) // 2
	if check(mid, 1) or check(mid, 0):
		r = mid
		ans = min(ans, mid)
	else:
		l = mid + 1
print(ans)


import math
import sys
from itertools import permutations
input = sys.stdin.readline
(n, K) = map(int, input().split())
arr = list(map(int, input().split()))
arr1 = list(arr)
arr2 = []
arr3 = []
arr4 = []
for i in range(1, n - 1):
	arr2.append(arr[i])
for i in range(1, n):
	arr4.append(arr[i])
for i in range(n - 1):
	arr3.append(arr[i])
arr1.sort()
arr2.sort()
arr3.sort()
arr4.sort()
glob1 = arr1[-1]
if n > 2:
	glob2 = arr2[-1]
else:
	glob2 = 1000000000000000000

def bs3(l, r, k):
	global arr, arr1, glob1
	if r >= l:
		mid = l + (r - l) // 2
		ans = []
		for i in range(n - 1):
			if arr[i] <= arr3[mid]:
				ans.append(i)
		flag = True
		fin = 0
		for i in range(len(ans) - 1):
			if flag:
				if abs(ans[i] - ans[i + 1]) <= 1:
					flag = False
				fin += 1
			else:
				flag = True
		if len(ans) >= 2 and flag == True:
			fin += 1
		if len(ans) == 1:
			fin = 1
		if fin >= k:
			glob1 = min(glob1, arr3[mid])
			return bs3(l, mid - 1, k)
		else:
			return bs3(mid + 1, r, k)
	else:
		return -1

def bs4(l, r, k):
	global arr, arr1, glob1
	if r >= l:
		mid = l + (r - l) // 2
		ans = []
		for i in range(1, n):
			if arr[i] <= arr4[mid]:
				ans.append(i)
		flag = True
		fin = 0
		for i in range(len(ans) - 1):
			if flag:
				if abs(ans[i] - ans[i + 1]) <= 1:
					flag = False
				fin += 1
			else:
				flag = True
		if len(ans) >= 2 and flag == True:
			fin += 1
		if len(ans) == 1:
			fin = 1
		if fin >= k:
			glob1 = min(glob1, arr4[mid])
			return bs4(l, mid - 1, k)
		else:
			return bs4(mid + 1, r, k)
	else:
		return -1

def bs1(l, r, k):
	global arr, arr1, glob1
	if r >= l:
		mid = l + (r - l) // 2
		ans = []
		for i in range(n):
			if arr[i] <= arr1[mid]:
				ans.append(i)
		flag = True
		fin = 0
		for i in range(len(ans) - 1):
			if flag:
				if abs(ans[i] - ans[i + 1]) <= 1:
					flag = False
				fin += 1
			else:
				flag = True
		if len(ans) >= 2 and flag == True:
			fin += 1
		if len(ans) == 1:
			fin = 1
		if fin >= k:
			glob1 = min(glob1, arr1[mid])
			return bs1(l, mid - 1, k)
		else:
			return bs1(mid + 1, r, k)
	else:
		return -1

def bs2(l, r, k):
	global arr, arr2, glob2
	if r >= l:
		mid = l + (r - l) // 2
		ans = []
		for i in range(1, n - 1):
			if arr[i] <= arr2[mid]:
				ans.append(i)
		flag = True
		fin = 0
		for i in range(len(ans) - 1):
			if flag:
				if abs(ans[i] - ans[i + 1]) <= 1:
					flag = False
				fin += 1
			else:
				flag = True
		if len(ans) >= 2 and flag == True:
			fin += 1
		if len(ans) == 1:
			fin = 1
		if fin >= k:
			glob2 = arr2[mid]
			return bs2(l, mid - 1, k)
		else:
			return bs2(mid + 1, r, k)
	else:
		return -1
if K % 2 == 0:
	bs4(0, n - 2, K // 2)
	bs3(0, n - 2, K // 2)
else:
	bs1(0, n - 1, K // 2 + 1)
	bs2(0, n - 3, K // 2)
	glob1 = min(glob1, glob2)
print(glob1)


(n, k) = input().split()
n = int(n)
k = int(k)
a = list(map(int, input().split()))
b = sorted(list(set(a)))

def check(x, flag):
	l = 0
	for i in range(len(a)):
		if flag or a[i] <= b[x]:
			l += 1
			flag ^= 1
	return l >= k
l = -1
r = len(b)
while l + 1 < r:
	mid = l + r >> 1
	if check(mid, 0) or check(mid, 1):
		r = mid
	else:
		l = mid
print(b[r])


def binarysearchodd(n, mid, k, arr):
	c = 0
	p = 1
	for i in range(n):
		if p % 2 == 1 and arr[i] <= mid:
			p += 1
			c += 1
		elif p % 2 == 0:
			p += 1
			c += 1
	return c

def binarysearcheven(n, mid, k, arr):
	c = 0
	p = 1
	for i in range(n):
		if p % 2 == 0 and arr[i] <= mid:
			p += 1
			c += 1
		elif p % 2 == 1:
			p += 1
			c += 1
	return c
(n, k) = map(int, input().split())
arr = [int(i) for i in input().split()]
l = 1
r = max(arr)
ans1 = r
while l <= r:
	mid = (l + r) // 2
	if binarysearchodd(n, mid, k, arr) >= k:
		ans1 = mid
		r = mid - 1
	elif binarysearcheven(n, mid, k, arr) >= k:
		ans1 = mid
		r = mid - 1
	else:
		l = mid + 1
print(ans1)


import sys
(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
(start, end) = (min(arr), max(arr))
ans = -1

def good(mid, curr):
	now = 'odd'
	temp = 0
	for i in range(n):
		if now == 'odd' and curr == 'odd':
			if arr[i] <= mid:
				temp += 1
				now = 'even'
			continue
		elif now == 'even' and curr == 'even':
			if arr[i] <= mid:
				temp += 1
				now = 'odd'
			continue
		else:
			temp += 1
			if now == 'odd':
				now = 'even'
			else:
				now = 'odd'
	return temp >= k
while start <= end:
	mid = (start + end) // 2
	if good(mid, 'odd') or good(mid, 'even'):
		ans = mid
		end = mid - 1
	else:
		start = mid + 1
print(ans)


def solve(cost, cm):
	cur = 0
	for i in a:
		if i <= cost or cur % 2 == cm:
			cur += 1
	return cur >= k
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(l, r) = (1, int(1000000000.0))
while l < r:
	mid = l + (r - l) // 2
	if solve(mid, 0) or solve(mid, 1):
		r = mid
	else:
		l = mid + 1
print(l)


(n, k) = map(int, input().split())

def jest(x, s, k1):
	bo = map(lambda y: y <= s, x)
	p = 0
	b = False
	for i in bo:
		if i:
			if b:
				b = False
			else:
				b = True
				p += 1
		else:
			b = False
	return p >= k1
a = list(map(int, input().split()))
kon = max(a)
pocz = min(a)
while pocz < kon:
	v = (pocz + kon) // 2
	if k % 2:
		if jest(a, v, k // 2 + 1) or jest(a[1:-1], v, k // 2):
			kon = v
		else:
			pocz = v + 1
	elif jest(a[:-1], v, k // 2) or jest(a[1:], v, k // 2):
		kon = v
	else:
		pocz = v + 1
print(kon)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
aOrderSorter = []
aOrderList = []
for i in range(n):
	aOrderSorter.append((a[i], i))
	aOrderList.append(-1)
aOrderSorter.sort(key=lambda x: x[0])
for i in range(n):
	aOrderList[aOrderSorter[i][1]] = i
if k % 2 == 0:
	k = k // 2
	oddMin = -1
	evenMin = -1
	l = 0
	r = k
	while r != l:
		m = (r + l) // 2
		subseq = []
		subseqLen = 0
		for i in range(n):
			if i == n - 1:
				break
			if aOrderList[i] < k + m and (subseqLen == 0 or subseq[subseqLen - 1] != i - 1):
				subseq.append(i)
				subseqLen += 1
				if subseqLen >= k:
					break
		if subseqLen >= k:
			r = m
		else:
			l = m + 1
	oddMin = r
	l = 0
	r = k
	while r != l:
		m = (r + l) // 2
		subseq = []
		subseqLen = 0
		for i in range(n):
			if i == 0:
				continue
			if aOrderList[i] < k + m and (subseqLen == 0 or subseq[subseqLen - 1] != i - 1):
				subseq.append(i)
				subseqLen += 1
				if subseqLen >= k:
					break
		if subseqLen >= k:
			r = m
		else:
			l = m + 1
	evenMin = r
	print(aOrderSorter[k + min(oddMin, evenMin) - 1][0])
else:
	k = k // 2
	l = 0
	r = k + 2
	while r != l:
		m = (r + l) // 2
		subseq = []
		subseqLen = 0
		for i in range(n):
			if aOrderList[i] < k + m and (subseqLen == 0 or subseq[subseqLen - 1] != i - 1):
				subseq.append(i)
				subseqLen += 1
				if subseqLen >= k + 1:
					break
		if subseqLen >= k + 1:
			r = m
		else:
			l = m + 1
	oddMin = r
	l = 0
	r = k
	while r != l:
		m = (r + l) // 2
		subseq = []
		subseqLen = 0
		for i in range(n):
			if i == 0:
				continue
			if i == n - 1:
				break
			if aOrderList[i] < k + m and (subseqLen == 0 or subseq[subseqLen - 1] != i - 1):
				subseq.append(i)
				subseqLen += 1
				if subseqLen >= k:
					break
		if subseqLen >= k:
			r = m
		else:
			l = m + 1
	evenMin = r
	print(aOrderSorter[k + min(oddMin, evenMin) - 1][0])


(n, k) = map(int, input().split())
a = [int(j) for j in input().split()]

def check(num, idx):
	ans = 0
	for i in range(n):
		if idx == 0:
			ans += 1
			idx = 1
		elif idx == 1 and a[i] <= num:
			ans += 1
			idx = 0
	return ans >= k

def bsearch(lo, hi):
	while lo < hi:
		mid = lo + (hi - lo) // 2
		if check(mid, 0) or check(mid, 1):
			hi = mid
		else:
			lo = mid + 1
	return lo
ans = bsearch(1, max(a))
print(ans)


(n, k) = map(int, input().split())
lo = 0
hi = 10 ** 9
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
		elif v <= test:
			odd += 1
			skip = True
	even = 0
	skip = True
	for v in l:
		if skip:
			skip = False
			even += 1
		elif v <= test:
			even += 1
			skip = True
	if odd >= k or even >= k:
		hi = test
	else:
		lo = test
print(hi)


def nd(lst, num, prc):
	dp = [0 for i in range(len(lst))]
	dp[0] = int(lst[0] <= prc)
	for i in range(1, len(lst)):
		if lst[i] > prc:
			dp[i] = dp[i - 1]
		elif i >= 2:
			dp[i] = max(dp[i - 1], dp[i - 2] + 2)
		else:
			dp[i] = 2
	return max(dp[-1], dp[-2] + 1) >= num
(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
l = min(lst)
r = max(lst)
while r - l > 1:
	m = (l + r) // 2
	if nd(lst, k, m):
		r = m
	else:
		l = m
if nd(lst, k, l):
	print(l)
else:
	print(r)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
OK = 10 ** 9
NG = 0
while OK - NG > 1:
	mid = (OK + NG) // 2
	B = []
	for a in A:
		if a <= mid:
			B.append(0)
		else:
			B.append(1)
	if k % 2 == 1:
		MIN = k // 2 + 1
		ind = 0
		ANS = 0
		while ind < n:
			if B[ind] == 0:
				ANS += 1
				ind += 2
			else:
				ind += 1
		if ANS >= MIN:
			OK = mid
			continue
		MIN = k // 2
		if B[0] == 0:
			B[0] = 1
		if B[-1] == 0:
			B[-1] = 1
		ind = 0
		ANS = 0
		while ind < n:
			if B[ind] == 0:
				ANS += 1
				ind += 2
			else:
				ind += 1
		if ANS >= MIN:
			OK = mid
			continue
		else:
			NG = mid
	else:
		MIN = k // 2
		ANS = 0
		ind = 0
		flag = 0
		while ind < n:
			if B[ind] == 0:
				if ind == n - 1:
					flag = 1
				ANS += 1
				ind += 2
			else:
				ind += 1
		ANS = 0
		ind = n - 1
		flag2 = 0
		while ind >= 0:
			if B[ind] == 0:
				if ind == 0:
					flag2 = 1
				ANS += 1
				ind -= 2
			else:
				ind -= 1
		if ANS == MIN and flag and flag2:
			NG = mid
		elif ANS >= MIN:
			OK = mid
		else:
			NG = mid
print(OK)


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

def check(n, k, m, a, flag):
	ans = 0
	for i in range(n):
		if not flag:
			ans += 1
			flag = 1 - flag
		elif a[i] <= m:
			ans += 1
			flag = 1 - flag
	return ans >= k

def main():
	starttime = datetime.datetime.now()
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	l = 1
	h = 1000000000.0
	while l < h:
		m = int(l + (h - l) // 2)
		if check(n, k, m, a, 0) or check(n, k, m, a, 1):
			h = m
		else:
			l = m + 1
	print(l)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
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')

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) = input().split(' ')
K = int(K)
A = input().split(' ')
A = list(map(int, A))

def choose(start, cost):
	count = 0
	i = start
	last_chosen = None
	while i < len(A):
		if A[i] <= cost:
			last_chosen = i
			count += 1
			i += 2
		else:
			i += 1
	return (count, last_chosen)
from functools import lru_cache

@lru_cache(maxsize=None)
def ok(cost):
	if K % 2 == 0:
		(r, lc) = choose(0, cost)
		if r >= K // 2 and lc != len(A) - 1:
			return True
		(r, lc) = choose(1, cost)
		if r >= K // 2:
			return True
	else:
		(r, lc) = choose(1, cost)
		if r >= K // 2 and lc != len(A) - 1:
			return True
		(r, lc) = choose(0, cost)
		if r >= (K + 1) // 2:
			return True
		return False

def ans2():
	for i in range(max(A)):
		if ok(i):
			return i

def ans():
	low = 0
	high = max(A)
	assert not ok(low)
	assert ok(high)
	while high - low > 2:
		mid = (low + high) // 2
		if ok(mid):
			high = mid
		else:
			low = mid
	for i in range(low - 2, low + 100):
		if ok(i):
			return i
print(ans())


import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

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

def main():

	def ok(i):
		s = ss[i]
		if k & 1:
			cnt = 0
			pre = False
			for a in aa:
				if pre:
					pre = False
					continue
				if a <= s:
					cnt += 1
					pre = True
				if cnt == k // 2 + 1:
					return True
			cnt = 0
			pre = False
			for a in aa[1:n - 1]:
				if pre:
					pre = False
					continue
				if a <= s:
					cnt += 1
					pre = True
				if cnt == k // 2:
					return True
		else:
			cnt = 0
			pre = False
			for a in aa[:n - 1]:
				if pre:
					pre = False
					continue
				if a <= s:
					cnt += 1
					pre = True
				if cnt == k // 2:
					return True
			cnt = 0
			pre = False
			for a in aa[1:]:
				if pre:
					pre = False
					continue
				if a <= s:
					cnt += 1
					pre = True
				if cnt == k // 2:
					return True
		return False
	(n, k) = MI()
	aa = LI()
	ss = list(sorted(set(aa)))
	sn = len(ss)
	l = -1
	r = sn
	while l + 1 < r:
		i = (l + r) // 2
		if ok(i):
			r = i
		else:
			l = i
	print(ss[r])
main()


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

def func(mid, flag, k):
	count = 0
	for i in range(n):
		if flag or arr[i] <= mid:
			count += 1
			flag ^= 1
	if count >= k:
		return True
	return False
low = 1
high = 10 ** 9
while low < high:
	mid = (low + high) // 2
	if func(mid, 0, k) or func(mid, 1, k):
		high = mid
	else:
		low = mid + 1
print(low)


import sys
input = sys.stdin.readline
f = lambda : list(map(int, input().split()))
_N = 1111111111
(n, k) = f()
inp = f()
(l, r) = (min(inp), max(inp))
ans = r
while l <= r:
	m = (l + r) // 2
	length = 0
	flag = False
	for i in inp:
		if length % 2:
			length += 1
		elif i <= m:
			length += 1
		else:
			pass
		if length >= k:
			flag = True
			break
	length = 0
	for i in inp:
		if not length % 2:
			length += 1
		elif i <= m:
			length += 1
		else:
			pass
		if length >= k:
			flag = True
			break
	if flag:
		ans = min(ans, m)
		r = m - 1
	else:
		l = m + 1
print(ans)


from sys import stdin, stdout

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

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

def isValidOdd(a, n, k, v):
	cnt = 0
	for x in a:
		if cnt % 2 == 0:
			if x <= v:
				cnt += 1
		else:
			cnt += 1
	return cnt >= k

def isValidEven(a, n, k, v):
	cnt = 0
	for x in a:
		if cnt % 2 == 1:
			if x <= v:
				cnt += 1
		else:
			cnt += 1
	return cnt >= k

def bs(a, n, k, l, h):
	ans = h
	while l <= h:
		mid = (l + h) // 2
		if isValidOdd(a, n, k, mid) or isValidEven(a, n, k, mid):
			ans = mid
			h = mid - 1
		else:
			l = mid + 1
	return ans
(n, k) = MI()
a = LI()
ans = bs(a, n, k, 1, 10 ** 9)
stdout.write(str(ans) + '\n')


import os
import sys
import math
from io import BytesIO, IOBase
import io
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
from collections import Counter
import threading
BUFSIZE = 8192

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10001)]
prime[0] = prime[1] = False

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

class DSU:

	def __init__(self, R, C):
		self.par = range(R * C + 1)
		self.rnk = [0] * (R * C + 1)
		self.sz = [1] * (R * C + 1)

	def find(self, x):
		if self.par[x] != x:
			self.par[x] = self.find(self.par[x])
		return self.par[x]

	def union(self, x, y):
		(xr, yr) = (self.find(x), self.find(y))
		if xr == yr:
			return
		if self.rnk[xr] < self.rnk[yr]:
			(xr, yr) = (yr, xr)
		if self.rnk[xr] == self.rnk[yr]:
			self.rnk[xr] += 1
		self.par[yr] = xr
		self.sz[xr] += self.sz[yr]

	def size(self, x):
		return self.sz[self.find(x)]

	def top(self):
		return self.size(len(self.sz) - 1) - 1

class LazySegTree:

	def __init__(self, _op, _e, _mapping, _composition, _id, v):

		def set(p, x):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			_d[p] = x
			for i in range(1, _log + 1):
				_update(p >> i)

		def get(p):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			return _d[p]

		def prod(l, r):
			assert 0 <= l <= r <= _n
			if l == r:
				return _e
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r >> i)
			sml = _e
			smr = _e
			while l < r:
				if l & 1:
					sml = _op(sml, _d[l])
					l += 1
				if r & 1:
					r -= 1
					smr = _op(_d[r], smr)
				l >>= 1
				r >>= 1
			return _op(sml, smr)

		def apply(l, r, f):
			assert 0 <= l <= r <= _n
			if l == r:
				return
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r - 1 >> i)
			l2 = l
			r2 = r
			while l < r:
				if l & 1:
					_all_apply(l, f)
					l += 1
				if r & 1:
					r -= 1
					_all_apply(r, f)
				l >>= 1
				r >>= 1
			l = l2
			r = r2
			for i in range(1, _log + 1):
				if l >> i << i != l:
					_update(l >> i)
				if r >> i << i != r:
					_update(r - 1 >> i)

		def _update(k):
			_d[k] = _op(_d[2 * k], _d[2 * k + 1])

		def _all_apply(k, f):
			_d[k] = _mapping(f, _d[k])
			if k < _size:
				_lz[k] = _composition(f, _lz[k])

		def _push(k):
			_all_apply(2 * k, _lz[k])
			_all_apply(2 * k + 1, _lz[k])
			_lz[k] = _id
		_n = len(v)
		_log = _n.bit_length()
		_size = 1 << _log
		_d = [_e] * (2 * _size)
		_lz = [_id] * _size
		for i in range(_n):
			_d[_size + i] = v[i]
		for i in range(_size - 1, 0, -1):
			_update(i)
		self.set = set
		self.get = get
		self.prod = prod
		self.apply = apply
MIL = 1 << 20

def makeNode(total, count):
	return total * MIL + count

def getTotal(node):
	return math.floor(node / MIL)

def getCount(node):
	return node - getTotal(node) * MIL
nodeIdentity = makeNode(0.0, 0.0)

def nodeOp(node1, node2):
	return node1 + node2
	return makeNode(getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2))
identityMapping = -1

def mapping(tag, node):
	if tag == identityMapping:
		return node
	count = getCount(node)
	return makeNode(tag * count, count)

def composition(mapping1, mapping2):
	return mapping1 if mapping1 != identityMapping else mapping2

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return math.gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = math.gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = math.gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
	factors = [1]
	for (p, exp) in prime_factors(n).items():
		factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]
	return factors

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def binarySearch(arr, n, i, key):
	left = 0
	right = n - 1
	mid = 0
	res = n
	while left <= right:
		mid = (right + left) // 2
		if arr[mid][i] > key:
			res = mid
			right = mid - 1
		else:
			left = mid + 1
	return res

def binarySearch1(arr, n, i, key):
	left = 0
	right = n - 1
	mid = 0
	res = -1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid][i] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
import os
import sys
import math
from io import BytesIO, IOBase
import io
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
from collections import Counter
import threading
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')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10001)]
prime[0] = prime[1] = False

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

class DSU:

	def __init__(self, R, C):
		self.par = range(R * C + 1)
		self.rnk = [0] * (R * C + 1)
		self.sz = [1] * (R * C + 1)

	def find(self, x):
		if self.par[x] != x:
			self.par[x] = self.find(self.par[x])
		return self.par[x]

	def union(self, x, y):
		(xr, yr) = (self.find(x), self.find(y))
		if xr == yr:
			return
		if self.rnk[xr] < self.rnk[yr]:
			(xr, yr) = (yr, xr)
		if self.rnk[xr] == self.rnk[yr]:
			self.rnk[xr] += 1
		self.par[yr] = xr
		self.sz[xr] += self.sz[yr]

	def size(self, x):
		return self.sz[self.find(x)]

	def top(self):
		return self.size(len(self.sz) - 1) - 1

class LazySegTree:

	def __init__(self, _op, _e, _mapping, _composition, _id, v):

		def set(p, x):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			_d[p] = x
			for i in range(1, _log + 1):
				_update(p >> i)

		def get(p):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			return _d[p]

		def prod(l, r):
			assert 0 <= l <= r <= _n
			if l == r:
				return _e
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r >> i)
			sml = _e
			smr = _e
			while l < r:
				if l & 1:
					sml = _op(sml, _d[l])
					l += 1
				if r & 1:
					r -= 1
					smr = _op(_d[r], smr)
				l >>= 1
				r >>= 1
			return _op(sml, smr)

		def apply(l, r, f):
			assert 0 <= l <= r <= _n
			if l == r:
				return
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r - 1 >> i)
			l2 = l
			r2 = r
			while l < r:
				if l & 1:
					_all_apply(l, f)
					l += 1
				if r & 1:
					r -= 1
					_all_apply(r, f)
				l >>= 1
				r >>= 1
			l = l2
			r = r2
			for i in range(1, _log + 1):
				if l >> i << i != l:
					_update(l >> i)
				if r >> i << i != r:
					_update(r - 1 >> i)

		def _update(k):
			_d[k] = _op(_d[2 * k], _d[2 * k + 1])

		def _all_apply(k, f):
			_d[k] = _mapping(f, _d[k])
			if k < _size:
				_lz[k] = _composition(f, _lz[k])

		def _push(k):
			_all_apply(2 * k, _lz[k])
			_all_apply(2 * k + 1, _lz[k])
			_lz[k] = _id
		_n = len(v)
		_log = _n.bit_length()
		_size = 1 << _log
		_d = [_e] * (2 * _size)
		_lz = [_id] * _size
		for i in range(_n):
			_d[_size + i] = v[i]
		for i in range(_size - 1, 0, -1):
			_update(i)
		self.set = set
		self.get = get
		self.prod = prod
		self.apply = apply
MIL = 1 << 20

def makeNode(total, count):
	return total * MIL + count

def getTotal(node):
	return math.floor(node / MIL)

def getCount(node):
	return node - getTotal(node) * MIL
nodeIdentity = makeNode(0.0, 0.0)

def nodeOp(node1, node2):
	return node1 + node2
	return makeNode(getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2))
identityMapping = -1

def mapping(tag, node):
	if tag == identityMapping:
		return node
	count = getCount(node)
	return makeNode(tag * count, count)

def composition(mapping1, mapping2):
	return mapping1 if mapping1 != identityMapping else mapping2

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return math.gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = math.gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = math.gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
	factors = [1]
	for (p, exp) in prime_factors(n).items():
		factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]
	return factors

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def binarySearch(arr, n, i, key):
	left = 0
	right = n - 1
	mid = 0
	res = n
	while left <= right:
		mid = (right + left) // 2
		if arr[mid][i] > key:
			res = mid
			right = mid - 1
		else:
			left = mid + 1
	return res

def binarySearch1(arr, n, i, key):
	left = 0
	right = n - 1
	mid = 0
	res = -1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid][i] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
t = 1
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = max(a)
	(left, right) = (1, ans)
	while left <= right:
		x = (left + right) // 2
		l = 0
		for i in range(n):
			if l % 2:
				l += 1
			elif a[i] <= x:
				l += 1
		l1 = 0
		for i in range(n):
			if l1 % 2 == 0:
				l1 += 1
			elif a[i] <= x:
				l1 += 1
		if l >= k or l1 >= k:
			right = x - 1
			ans = x
		else:
			left = x + 1
	print(ans)


from math import sqrt
it = lambda : list(map(int, input().strip().split()))

def possible(A, N, K, mi):
	dp1 = [0] * (N + 2)
	dp2 = [0] * (N + 2)
	if K % 2:
		for i in range(N):
			dp1[i + 2] = dp1[i] + 1 if A[i] <= mi else dp1[i + 1]
		for i in range(1, N - 1):
			dp2[i + 2] = dp2[i] + 1 if A[i] <= mi else dp2[i + 1]
		return dp1[N + 1] >= (K + 1) // 2 or dp2[N] >= K // 2
	else:
		for i in range(1, N):
			dp1[i + 2] = dp1[i] + 1 if A[i] <= mi else dp1[i + 1]
		for i in range(N - 1):
			dp2[i + 2] = dp2[i] + 1 if A[i] <= mi else dp2[i + 1]
		return dp1[N + 1] >= K // 2 or dp2[N] >= K // 2

def solve():
	(N, K) = it()
	A = it()
	lo = 1
	hi = 10 ** 9
	while lo < hi:
		mi = lo + hi >> 1
		if possible(A, N, K, mi):
			hi = mi
		else:
			lo = mi + 1
	print(lo)
solve()


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

def done(x, s):
	c = 0
	for i in range(len(arr)):
		if s or arr[i] <= x:
			c += 1
			s = s ^ 1
	return c >= k
lb = 1
rb = max(arr)
ans = rb
while lb < rb:
	mid = (lb + rb) // 2
	if done(mid, 0) or done(mid, 1):
		rb = mid
		ans = min(ans, mid)
	else:
		lb = mid + 1
print(ans)


def check(m):
	ans = []
	for i in range(n):
		if len(ans) % 2 == 0 and len(ans) < k:
			if A[i] <= m:
				ans.append(A[i])
		elif len(ans) % 2 == 1 and len(ans) < k:
			ans.append(A[i])
	if len(ans) == k:
		return 1
	else:
		ans = []
		for i in range(n):
			if len(ans) % 2 == 1 and len(ans) < k:
				if A[i] <= m:
					ans.append(A[i])
			elif len(ans) % 2 == 0 and len(ans) < k:
				ans.append(A[i])
		if len(ans) == k:
			return 1
		return 0
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
high = 10 ** 9
low = 1
ans = 10 ** 9
while low <= high:
	m = (high + low) // 2
	if check(m):
		ans = m
		high = m - 1
	else:
		low = m + 1
print(ans)


(N, K) = map(int, input().split())
(*A,) = map(int, input().split())

def check(A, x, s):
	cnt = s
	i = s
	while i < N:
		if A[i] <= x:
			cnt += 1 if i == N - 1 else 2
			i += 2
			continue
		i += 1
	if cnt >= K:
		return True
	else:
		return False
L = 0
R = 10 ** 9
while L + 1 < R:
	mid = (L + R) // 2
	if check(A, mid, 0) or check(A, mid, 1):
		R = mid
	else:
		L = mid
print(L + 1)


import sys
input = sys.stdin.readline
inputr = lambda : input().rstrip('\n')
INF = 10 ** 18
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
if k == 1:
	print(min(A))
	sys.exit(0)
need = k // 2

def test(V, takeo):
	g = 0
	o = 0
	for v in A:
		if takeo:
			o += 1
			takeo = False
		elif v <= V:
			g += 1
			takeo = True
		if o + g == k:
			return True
	return False
SA = sorted(set(A))
lo = 0
hi = len(SA)
best = INF
while lo < hi:
	m = (lo + hi) // 2
	V = SA[m]
	if test(V, False) or test(V, True):
		best = min(best, V)
		hi = m
	else:
		lo = m + 1
print(best)


def check(a, pos):
	u = 0
	for i in range(n):
		if pos == 0:
			u += 1
			pos = 1
		elif t[i] <= a:
			u += 1
			pos = 0
	if u >= k:
		return 1
	else:
		return 0

def bina(l, r):
	while l < r:
		m = l + (r - l) // 2
		if check(m, 0) | check(m, 1):
			r = m
		else:
			l = m + 1
	return l
import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
t = list(map(int, input().split()))
print(bina(1, 1000000000))


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

def binarysearch(mid, s, k):
	c = 0
	for i in range(n):
		if s or a[i] <= mid:
			c += 1
			s ^= 1
	if c >= k:
		return True
	return False
l = 1
h = 10 ** 9
while l < h:
	mid = (l + h) // 2
	if binarysearch(mid, 0, k) or binarysearch(mid, 1, k):
		h = mid
	else:
		l = mid + 1
print(l)


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict as dd
(n, k, ar) = (0, 0, [])

def check(x):
	(ct1, ct2) = (0, 0)
	flg = 1
	for i in range(n):
		if ar[i] <= x and flg:
			flg = 0
			ct1 += 1
		elif not flg:
			flg = 1
			ct1 += 1
	flg = 0
	for i in range(n):
		if ar[i] <= x and flg:
			flg = 0
			ct2 += 1
		elif not flg:
			flg = 1
			ct2 += 1
	return ct1 >= k or ct2 >= k

def src(l, r):
	while l < r:
		mid = (l + r) // 2
		if check(mid):
			r = mid
		else:
			l = mid + 1
	return l

def main():
	global n, k, ar
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	(r, l) = (max(ar), min(ar))
	print(src(l, r))
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')
main()


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
(n, k) = inputnums()
a = inputlist()

def check(x, cur):
	ans = 0
	for i in range(n):
		if not cur:
			ans += 1
			cur = 1
		elif a[i] <= x:
			ans += 1
			cur = 0
	return ans >= k

def binsearch(lo, hi):
	while lo < hi:
		mid = (lo + hi) // 2
		if check(mid, 0) or check(mid, 1):
			hi = mid
		else:
			lo = mid + 1
	return lo
print(binsearch(1, 1000000000))


global n, k

def f(x):
	cc = 0
	for i in range(n):
		if cc == k:
			break
		if cc % 2 != 1 and a[i] <= x:
			cc += 1
		elif cc % 2 == 1:
			cc += 1
	if cc == k:
		return True
	cc = 0
	for i in range(n):
		if cc == k:
			break
		if cc % 2 == 1 and a[i] <= x:
			cc += 1
		elif cc % 2 == 0:
			cc += 1
	if cc == k:
		return True
	return False
(n, k) = map(int, input().split())
a = [int(o) for o in input().split()]
a1 = sorted(a)
hi = n - 1
low = 0
while low <= hi:
	mid = (hi + low) // 2
	if f(a1[mid]):
		hi = mid - 1
	else:
		low = mid + 1
print(a1[low])


from collections import Counter
from collections import defaultdict
from collections import deque
import math
import heapq
import sys
import io, os
input = sys.stdin.readline
from bisect import *
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().strip().split()))
rls = lambda : list(map(str, input().split()))

def check(m):
	c = 0
	d = s
	f1 = 1
	f2 = 1
	mn = 10 ** 9
	p = []
	for i in range(0, n):
		if c % 2 == 0:
			if a[i] > m:
				d = d - 1
			else:
				p.append(a[i])
				c = c + 1
		else:
			p.append(a[i])
			c = c + 1
		if d < 0:
			f1 = 0
	d = s
	c = 0
	for i in range(0, n):
		if c % 2 != 0:
			if a[i] > m:
				d = d - 1
			else:
				c = c + 1
		else:
			c = c + 1
		if d < 0:
			f2 = 0
	if f1 or f2:
		return 1
	return 0
(n, k) = rl()
s = n - k
a = rl()
l = 0
r = max(a)
ans = r
while l <= r:
	mid = l + (r - l) // 2
	if check(mid) == 1:
		ans = min(ans, mid)
		r = mid - 1
	else:
		l = mid + 1
print(ans)


import sys
input = sys.stdin.buffer.readline

def possible(start, k, x):
	c = 0
	for i in range(start, len(arr)):
		if c % 2 == 1:
			c += 1
		elif arr[i] <= x:
			c += 1
		if c == k:
			return True
	return False
(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
maxCost = max(arr)
b = maxCost // 2 + 1
maxImpossible = -1
while b > 0:
	while possible(1, k - 1, maxImpossible + b) == possible(0, k, maxImpossible + b) == False:
		maxImpossible += b
	b //= 2
minCost = maxImpossible + 1
print(minCost)


from bisect import *
from collections import *
from math import *
from heapq import *
from typing import List
from itertools import *
from operator import *
from functools import *

@lru_cache(None)
def fact(x):
	if x < 2:
		return 1
	return fact(x - 1) * x

@lru_cache(None)
def per(i, j):
	return fact(i) // fact(i - j)

@lru_cache(None)
def com(i, j):
	return per(i, j) // fact(j)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

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

def power2(n):
	while not n & 1:
		n >>= 1
	return n == 1
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
r = max(arr)

def fun(x):
	odd = even = 0
	for i in range(n):
		if odd & 1 or arr[i] <= x:
			odd += 1
		if not even & 1 or arr[i] <= x:
			even += 1
	return max(odd, even)
print(linc(fun, k, 1, r))


import sys
(n, k) = (0, 0)
ans = 1000000000
a = []

def ok(mid):
	for i in [0, 1]:
		l = 0
		for val in a:
			if l % 2 != i or val <= mid:
				l += 1
		if l >= k:
			return True
	return False

def solve():
	global n, k
	global a
	global ans
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	lo = 1
	hi = max(a[0:])
	while lo <= hi:
		mid = int((lo + hi) / 2)
		if ok(mid):
			ans = mid
			hi = mid - 1
		else:
			lo = mid + 1
	print(ans)

def main():
	solve()
main()


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

def check(limit, p):
	count = 0
	for i in range(len(arr)):
		if p:
			count += 1
			p = 0
		elif arr[i] <= limit:
			count += 1
			p = 1
	return count >= k
l = 1
r = 10 ** 9
ans = 0
while l <= r:
	mid = l + (r - l) // 2
	if check(mid, 0) or check(mid, 1):
		ans = mid
		r = mid - 1
	else:
		l = mid + 1
print(ans)


(N, K) = map(int, input().split(' '))
a = [int(x) for x in input().split(' ')]

def solve(b):
	c = [0 for _ in range(len(b))]
	for (i, x) in enumerate(b):
		if i == 0:
			c[i] = 1 if x else 0
		else:
			c[i] = c[i - 1]
			if x:
				c[i] = max(c[i], 1 + (c[i - 2] if i >= 2 else 0))
	return c[-1]

def ok(maxv):
	if K % 2 == 0:
		b = [x <= maxv for x in a[1:]]
		c = [x <= maxv for x in a[:-1]]
		return solve(b) >= K // 2 or solve(c) >= K // 2
	else:
		b = [x <= maxv for x in a]
		c = [x <= maxv for x in a[1:-1]]
		return solve(b) >= (K + 1) // 2 or solve(c) >= (K - 1) // 2
(lo, hi) = (1, int(1000000000.0))
while lo != hi:
	mi = (lo + hi) // 2
	if ok(mi):
		hi = mi
	else:
		lo = mi + 1
print(lo)


def check(a, m, chk, k):
	ct = 0
	for i in a:
		if i <= m or ct % 2 != chk:
			ct += 1
	if ct >= k:
		return True
	else:
		return False
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 1
h = 10 ** 9 + 1
m = 0
while l < h:
	m = (l + h) // 2
	if check(a, m, 0, k) or check(a, m, 1, k):
		h = m
	else:
		l = m + 1
print(l)


import sys

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 ** 19
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
	ok = mx
	ng = mn
	while ng + 1 < ok:
		mid = (ok + ng) // 2
		if func(mid):
			ok = mid
		else:
			ng = mid
	return ok

def check(m):
	cnt1 = 0
	cnt2 = 0
	i = 0
	while i < N:
		if A[i] <= m:
			cnt1 += 1
			i += 1
			if i < N:
				cnt2 += 1
				i += 1
		else:
			i += 1
	cnt3 = 0
	cnt4 = 1
	i = 1
	while i < N:
		if A[i] <= m:
			cnt3 += 1
			i += 1
			if i < N:
				cnt4 += 1
				i += 1
		else:
			i += 1
	return cnt1 >= ceil(K, 2) and cnt1 + cnt2 >= K or (cnt3 >= K // 2 and cnt3 + cnt4 >= K)
(N, K) = MAP()
A = LIST()
res = bisearch_min(0, 10 ** 9 + 1, check)
print(res)


rr = lambda : input()
rri = lambda : int(input())
rrm = lambda : list(map(int, input().split()))
INF = float('inf')

def check(val, cur, A):
	ans = 0
	for v in A:
		if cur:
			ans += 1
			cur ^= 1
		elif v <= val:
			ans += 1
			cur ^= 1
	return ans >= k

def solve(N, K, A):
	(lo, hi) = (1, 10 ** 9)
	while lo <= hi:
		mid = lo + hi >> 1
		if check(mid, 0, A) or check(mid, 1, A):
			hi = mid - 1
		else:
			lo = mid + 1
	return lo
(n, k) = rrm()
arr = rrm()
print(solve(n, k, arr))


import os
import sys
from io import BytesIO, IOBase
import threading
from math import floor
from bisect import bisect_right
from collections import deque
from math import gcd
mod = 998244353

def main():
	for _ in range(1):
		(n, k) = map(int, input().split())
		arr = list(map(int, input().split()))
		a = arr.copy()
		arr = list(zip(arr, range(0, n)))
		arr.sort()
		l = 0
		r = len(arr) - 1
		ans = -1
		while l <= r:
			mid_i = l + (r - l) // 2
			mid_e = arr[mid_i][0]
			if l == r:
				ans = mid_e
				break
			prev = -2
			cnt1 = 0
			for i in range(n if k % 2 == 1 else n - 1):
				if a[i] <= mid_e and i - prev > 1:
					prev = i
					cnt1 += 1
			prev = -2
			cnt2 = 0
			for i in range(1, n if k % 2 == 0 else n - 1):
				if a[i] <= mid_e and i - prev > 1:
					prev = i
					cnt2 += 1
			if cnt2 >= k // 2 or cnt1 >= (k + 1) // 2:
				r = mid_i
			else:
				l = mid_i + 1
		print(ans)
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')
main()


def check(x):
	(ct1, ct2) = (0, 0)
	flg = 1
	for i in range(n):
		if ar[i] <= x and flg:
			flg = 0
			ct1 += 1
		elif not flg:
			flg = 1
			ct1 += 1
	flg = 0
	for i in range(n):
		if ar[i] <= x and flg:
			flg = 0
			ct2 += 1
		elif not flg:
			flg = 1
			ct2 += 1
	return ct1 >= k or ct2 >= k

def src(l, r):
	while l < r:
		mid = (l + r) // 2
		if check(mid):
			r = mid
		else:
			l = mid + 1
	return l
(n, k) = map(int, input().split())
ar = list(map(int, input().split()))
(r, l) = (max(ar), min(ar))
print(src(l, r))


def check(x, cur):
	ans = 0
	for i in range(n):
		if cur == 0:
			ans += 1
			cur = 1 - cur
		elif lt[i] <= x:
			ans += 1
			cur = 1 - cur
	return ans >= k
(n, k) = map(int, input().split())
lt = [int(x) for x in input().split()]
(l, h) = (min(lt), max(lt))
while l < h:
	mid = (l + h) // 2
	if check(mid, 0) or check(mid, 1):
		h = mid
	else:
		l = mid + 1
print(l)


import collections
import time
import os
import sys
import bisect
import heapq
from typing import List

def solve(N, K, A):

	def check_impl(val, odd):
		s = 0 if odd else 1
		i = 0 if odd else 1
		while i < N:
			if A[i] <= val:
				s += 1
				if s >= K:
					break
				if i + 1 < N:
					s += 1
				i += 2
			else:
				i += 1
		return s >= K

	def check(val):
		return check_impl(val, True) or check_impl(val, False)
	(lo, hi) = (0, max(A))
	while lo <= hi:
		m = (lo + hi) // 2
		if check(m):
			hi = m - 1
		else:
			lo = m + 1
	return lo
(N, K) = map(int, input().split())
A = [int(x) for x in input().split()]
print(solve(N, K, A))


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

def fun(p, pp):
	cnt = 0
	for i in range(n):
		if arr[i] <= p or cnt % 2 == pp:
			cnt += 1
		if cnt == k:
			return True
	return False
(low, high) = (min(arr), max(arr))
ans = high
while low < high:
	mid = (low + high) // 2
	if fun(mid, 0) or fun(mid, 1):
		high = mid
		ans = mid
	else:
		low = mid + 1
print(ans)


import sys
input = sys.stdin.buffer.readline
(n, k) = map(int, input().split())
ls = list(map(int, input().split()))

def check(mx):
	for open in range(2):
		cc = 0
		for u in ls:
			if u <= mx and open:
				cc += 1
				open = 0
			elif not open:
				cc += 1
				open = 1
			if cc >= k:
				return True
	return False
(l, r) = (1, max(ls) + 1)
while l < r:
	m = (l + r) // 2
	if check(m):
		r = m
	else:
		l = m + 1
print(l)


import io
import os
from collections import Counter, defaultdict, deque

def bisect_f(f, lo, hi):
	assert f(lo) and (not f(hi))
	while hi - lo > 1:
		mid = (lo + hi) // 2
		if f(mid):
			lo = mid
		else:
			hi = mid
	assert f(lo) and (not f(hi))
	return lo

def solve(N, K, A):

	def isPossible(val):
		indices = []
		for (i, x) in enumerate(A):
			if x <= val:
				indices.append(i)
		if not indices:
			return False
		oddIndices = list(indices)
		if K % 2 == 0:
			if oddIndices[-1] == N - 1:
				oddIndices.pop()
		evenIndices = list(indices)
		if evenIndices[0] == 0:
			evenIndices = evenIndices[1:]
		if K % 2 == 1:
			if evenIndices and evenIndices[-1] == N - 1:
				evenIndices.pop()

		def getBest(indices):
			if not indices:
				return 0
			chunks = [1]
			for i in range(1, len(indices)):
				if indices[i] != indices[i - 1] + 1:
					chunks.append(1)
				else:
					chunks[-1] += 1
			count = 0
			for c in chunks:
				count += (c + 1) // 2
			return count
		oddBest = getBest(oddIndices)
		evenBest = getBest(evenIndices)
		if K % 2 == 1:
			return oddBest >= (K + 1) // 2 or evenBest >= K // 2
		else:
			return oddBest >= K // 2 or evenBest >= K // 2

	def isNotPossible(val):
		return not isPossible(val)
	lo = 0
	hi = 10 ** 9
	index = bisect_f(isNotPossible, lo, hi)
	return index + 1
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N, K) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = solve(N, K, A)
print(ans)


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
mod = 10 ** 9 + 7
mod1 = 998244353
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')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class BinaryTrie:

	class Node:

		def __init__(self, bit: bool=False):
			self.bit = bit
			self.children = []
			self.count = 0
			self.counter = 1

	def __init__(self, size):
		self.root = BinaryTrie.Node()
		self.size = size

	def convert(self, key):
		bits = []
		if isinstance(key, int):
			key = bin(key)[2:]
		if isinstance(key, str):
			for i in range(self.size - len(key)):
				bits += [False]
			for i in key:
				if i == '0':
					bits += [False]
				else:
					bits += [True]
		else:
			return list(key)
		return bits

	def add(self, key):
		node = self.root
		bits = self.convert(key)
		for bit in bits:
			found_in_child = False
			for child in node.children:
				if child.bit == bit:
					child.counter += 1
					node = child
					found_in_child = True
					break
			if not found_in_child:
				new_node = BinaryTrie.Node(bit)
				node.children.append(new_node)
				node = new_node
		node.count += 1

	def remove(self, key):
		node = self.root
		bits = self.convert(key)
		nodelist = [node]
		for bit in bits:
			for child in node.children:
				if child.bit == bit:
					node = child
					node.counter -= 1
					nodelist.append(node)
					break
		node.count -= 1
		if not node.children and (not node.count):
			for i in range(len(nodelist) - 2, -1, -1):
				nodelist[i].children.remove(nodelist[i + 1])
				if nodelist[i].children or nodelist[i].count:
					break

	def query(self, prefix, root=None):
		if not root:
			root = self.root
		node = root
		if not root.children:
			return 0
		for bit in prefix:
			bit_not_found = True
			for child in node.children:
				if child.bit == bit:
					bit_not_found = False
					node = child
					break
			if bit_not_found:
				return 0
		return node

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.data = 0
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key, val):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
			pCrawl.data += val
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		c = 0
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None

	def present(self, key):
		ans = 0
		pCrawl = self.root
		length = len(key)
		c = 0
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
			ans += pCrawl.data
		if pCrawl != None:
			return ans
		return -1
(n, k) = map(int, input().split())
l = list(map(int, input().split()))

def find(x):
	w = []
	size = 0
	for i in range(n):
		if size % 2 == 0:
			w.append(l[i])
			size += 1
		elif l[i] <= x:
			w.append(l[i])
			size += 1
	if len(w) >= k:
		return True
	w = []
	size = 0
	for i in range(n):
		if size % 2 == 1:
			w.append(l[i])
			size += 1
		elif l[i] <= x:
			w.append(l[i])
			size += 1
	if len(w) >= k:
		return True
	return False
st = 1
end = max(l)
ans = end
while st <= end:
	mid = (st + end) // 2
	if find(mid) == True:
		end = mid - 1
		ans = mid
	else:
		st = mid + 1
print(ans)


import sys
input = sys.stdin.buffer.readline

def solution():
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	beg = 1
	end = 10 ** 9
	ans = 2e+19
	while beg <= end:
		mid = (beg + end) // 2
		l1 = 0
		for i in range(n):
			if l1 % 2 == 1 and l[i] <= mid:
				l1 += 1
			elif l1 % 2 == 0:
				l1 += 1
		l2 = 0
		for i in range(n):
			if l2 % 2 == 0 and l[i] <= mid:
				l2 += 1
			elif l2 % 2 == 1:
				l2 += 1
		if max(l2, l1) >= k:
			ans = min(ans, mid)
			end = mid - 1
		else:
			beg = mid + 1
	print(ans)
solution()


from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))

def odd_even_subsequence(n, k, a):
	res1 = 10000000000
	res2 = 10000000000
	if k % 2 == 0:
		v = a.pop(-1)
		res1 = subsequence(n, k // 2 + k % 2, a)
		a.append(v)
	else:
		res1 = subsequence(n, k // 2 + k % 2, a)
	if k % 2 == 0:
		a.pop(0)
		res2 = subsequence(n, k // 2, a)
	else:
		a.pop(0)
		a.pop(-1)
		res2 = subsequence(n, k // 2, a)
	return min(res1, res2)

def subsequence(n, k, a):
	l = 0
	h = 10 ** 9
	while l < h:
		m = (l + h) // 2
		if calc(a, m, k):
			h = m
		else:
			l = m + 1
	return h

def calc(a, v, k):
	pre1 = 0
	pre2 = 0
	for i in range(len(a)):
		cur = pre1
		if a[i] <= v:
			cur = max(1 + pre2, pre1)
		pre2 = pre1
		pre1 = cur
	return pre1 >= k
print(str(odd_even_subsequence(n, k, a)))


from fractions import Fraction
import bisect
import os
import io
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

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

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

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 isPossible(value, isEven):
	subsequence_size = 0
	for i in a:
		if isEven:
			if i <= value:
				subsequence_size += 1
				isEven = False
		else:
			subsequence_size += 1
			isEven = True
	return k <= subsequence_size

def bin_search(l, r):
	while l < r:
		mid = (l + r) // 2
		if isPossible(mid, True) or isPossible(mid, False):
			r = mid
		else:
			l = mid + 1
	return l
t = 1
for _ in range(t):
	(n, k) = rinput()
	a = rlinput()
	print(bin_search(0, int(1000000000.0)))


(n, k) = map(int, input().rstrip().split())
l = list(map(int, input().rstrip().split()))
s = sorted(l)
left = 0
right = len(s) - 1
while left < right:
	mid = (left + right) // 2
	guess = s[mid]
	separatore = False
	counter = 0
	cons = 0
	for el in l:
		if el > guess:
			if cons == 0:
				pass
			elif cons % 2:
				counter += cons
			else:
				counter += cons - 1
			cons = 0
			if not separatore:
				separatore = True
				counter += 1
		elif separatore:
			separatore = False
			cons = 1
		else:
			cons += 1
	if cons == 0:
		pass
	elif cons % 2:
		counter += cons
	else:
		counter += cons - 1
	cons = 0
	for i in range(n):
		if l[i] <= guess:
			cons += 1
		else:
			break
	if cons > 0 and cons % 2 == 0 and (cons < n - 1):
		counter += 1
	cons = 0
	for i in range(n - 1, -1, -1):
		if l[i] <= guess:
			cons += 1
		else:
			break
	if cons > 0 and cons % 2 == 0:
		counter += 1
	if counter >= k:
		right = mid
	else:
		left = mid + 1
print(s[left])


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys

def main():
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))

	def judge(x):
		flag = 0
		(cnt0, cnt1) = (0, 0)
		for a in A:
			if flag:
				flag ^= 1
				cnt0 += 1
			elif a <= x:
				cnt0 += 1
				flag ^= 1
		flag = 1
		for a in A:
			if flag:
				flag ^= 1
				cnt1 += 1
			elif a <= x:
				cnt1 += 1
				flag ^= 1
		return max(cnt0, cnt1) >= k
	(ng, ok) = (0, 10 ** 10)
	while ok - ng > 1:
		mid = (ng + ok) // 2
		if judge(mid):
			ok = mid
		else:
			ng = mid
	sys.stdout.write(str(ok) + '\n')
main()


(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
l = -1
r = 10 ** 9
while r - l != 1:
	tmp = 0
	j = 0
	mid = (r + l) // 2
	while j < len(arr):
		if arr[j] <= mid:
			tmp += 1
			if j != len(arr) - 1:
				tmp += 1
			j += 2
		else:
			j += 1
	if tmp >= k:
		r = mid
	else:
		l = mid
r1 = r
l = -1
r = 10 ** 9
l = -1
r = 10 ** 9
while r - l != 1:
	tmp = 1
	j = 1
	mid = (r + l) // 2
	while j < len(arr):
		if arr[j] <= mid:
			tmp += 1
			if j != len(arr) - 1:
				tmp += 1
			j += 2
		else:
			j += 1
	if tmp >= k:
		r = mid
	else:
		l = mid
print(min(r1, r))


def ki(i):
	c = 0
	f = 0
	for (j, x) in enumerate(X):
		if j == N - 1 and K % 2 == 0:
			continue
		if x <= i and (not f):
			c += 1
			f = 1
			if c >= (K + 1) // 2:
				return True
			continue
		f = 0
	return False

def gu(i):
	c = 0
	f = 0
	for (j, x) in enumerate(X):
		if j == 0:
			continue
		if j == N - 1 and K % 2:
			continue
		if x <= i and (not f):
			c += 1
			f = 1
			if c >= K // 2:
				return True
			continue
		f = 0
	return False

def f(i):
	return ki(i) or gu(i)

def bsearch(mn, mx, func):
	idx = (mx + mn) // 2
	while mx - mn > 1:
		if func(idx):
			(idx, mx) = ((idx + mn) // 2, idx)
			continue
		(idx, mn) = ((idx + mx) // 2, idx)
	return idx
(N, K) = map(int, input().split())
X = list(map(int, input().split()))
i = bsearch(min(X) - 1, max(X), f)
print(i + 1)


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

def f(x):
	global n, k, a
	check = 0
	now = 1
	for i in range(n):
		if now:
			if a[i] <= x:
				now = 1 - now
				check += 1
		else:
			now = 1 - now
			check += 1
	if check >= k:
		return True
	check = 0
	now = 0
	for i in range(n):
		if now:
			if a[i] <= x:
				now = 1 - now
				check += 1
		else:
			now = 1 - now
			check += 1
	if check >= k:
		return True
	else:
		return False
(l, r) = (0, 10 ** 9 + 1)
while l + 1 < r:
	m = l + (r - l) // 2
	if f(m):
		r = m
	else:
		l = m
print(r)


import sys
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n, k) = I()
a = I()
(lo, hi) = (1, INF)

def check(x):
	global k, n
	cur = 0
	(cnt0, cnt1) = (0, 0)
	for i in range(n):
		if cur:
			cur ^= 1
			cnt0 += 1
		elif a[i] <= x:
			cnt0 += 1
			cur ^= 1
	cur = 1
	for i in range(n):
		if cur:
			cur ^= 1
			cnt1 += 1
		elif a[i] <= x:
			cnt1 += 1
			cur ^= 1
	return max(cnt0, cnt1) >= k
while lo < hi:
	mid = (lo + hi) // 2
	if check(mid):
		hi = mid
	else:
		lo = mid + 1
print(lo)


A = input().split(' ')
n = int(A[0])
k = int(A[1])
a = input().split(' ')
for i in range(n):
	a[i] = int(a[i])
r = 1000000000
l = 0
even = 0
odd = 0
while r - l > 1:
	even = 0
	odd = 0
	mid = int((r + l) // 2)
	kk = 1
	for j in range(n):
		if kk == 1:
			even += 1
			kk = 2
		elif a[j] <= mid:
			even += 1
			kk = 1
	kk = 1
	for j in range(n):
		if kk == 2:
			odd += 1
			kk = 1
		elif a[j] <= mid:
			odd += 1
			kk = 2
	if odd >= k or even >= k:
		r = mid
	else:
		l = mid
print(r)


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def main():
	(n, k) = map(int, inputi().split())
	aa = [int(a) for a in inputi().split()]
	lo = 0
	hi = max(aa) + 1
	while lo < hi:
		mid = (lo + hi) // 2
		if valid_sequence(aa, k, mid, n):
			hi = mid
		else:
			lo = mid + 1
	print(lo)

def valid_sequence(aa, k, mid, n):
	i = 0
	count = 0
	while i < n - 1 + k % 2 and count < (k + 1) // 2:
		if aa[i] <= mid:
			i += 2
			count += 1
		else:
			i += 1
	found = count == (k + 1) // 2
	if not found:
		i = 1
		count = 0
		while i < n - k % 2 and count < k // 2:
			if aa[i] <= mid:
				i += 2
				count += 1
			else:
				i += 1
		found = count == k // 2
	return found
main()


def isValidOdd(mid):
	cnt = 0
	for x in range(n):
		if cnt % 2 == 0:
			if arr[x] <= mid:
				cnt += 1
		else:
			cnt += 1
	if cnt >= k:
		return True
	return False

def isValidEven(mid):
	cnt = 0
	for x in range(n):
		if cnt % 2 == 1:
			if arr[x] <= mid:
				cnt += 1
		else:
			cnt += 1
	if cnt >= k:
		return True
	return False

def bs(left, right):
	ans = right
	while left <= right:
		mid = (left + right) // 2
		if isValidOdd(mid) or isValidEven(mid):
			right = mid - 1
			ans = mid
		else:
			left = mid + 1
	print(ans)
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
bs(1, max(arr))


t = 1

def fun_odd(num, a):
	cnt = 0
	for i in a:
		if cnt % 2 == 0:
			if i <= num:
				cnt += 1
			else:
				continue
		else:
			cnt += 1
	return cnt

def fun_ev(num, a):
	cnt = 0
	for i in a:
		if cnt % 2 == 1:
			if i <= num:
				cnt += 1
			else:
				continue
		else:
			cnt += 1
	return cnt

def fun(x, arr):
	t1 = fun_odd(x, arr)
	t2 = fun_ev(x, arr)
	if t1 >= k or t2 >= k:
		return True
	return False
for _ in range(t):
	(n, k) = list(map(int, input().rstrip().split()))
	a = list(map(int, input().rstrip().split()))
	l = min(a) - 1
	r = max(a) + 1
	while l <= r:
		mid = (l + r) // 2
		if fun(mid, a):
			r = mid - 1
		else:
			l = mid + 1
	print(l)


def can_alterate(vs, max_v, num_to_take, begin_i, end_i):
	i = begin_i
	while i < end_i and num_to_take > 0:
		if vs[i] <= max_v:
			i += 1
			num_to_take -= 1
		i += 1
	return num_to_take == 0

def can_fit_max(vs, max_v, num_to_take):
	return can_alterate(vs, max_v, (num_to_take + 1) // 2, 0, len(vs) - 1 + num_to_take % 2) or can_alterate(vs, max_v, num_to_take // 2, 1, len(vs) - num_to_take % 2)

def main():
	(n, k) = [int(t) for t in input().strip().split()]
	vs = [int(t) for t in input().strip().split()]
	min_target = 0
	max_target = max(vs)
	while max_target > min_target + 1:
		mid_target = (min_target + max_target) // 2
		if can_fit_max(vs, mid_target, k):
			max_target = mid_target
		else:
			min_target = mid_target
	print(max_target)
main()


def canform1(lst, n, k, x):
	count = 0
	for i in range(n):
		if count % 2 == 0 and lst[i] <= x:
			count += 1
		elif count % 2 != 0:
			count += 1
	if count >= k:
		return True
	else:
		return False

def canform2(lst, n, k, x):
	count = 0
	for i in range(n):
		if count % 2 != 0 and lst[i] <= x:
			count += 1
		elif count % 2 == 0:
			count += 1
	if count >= k:
		return True
	else:
		return False
(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
(low, high) = (min(lst), max(lst))
ans = high
while low <= high:
	mid = (low + high) // 2
	if canform1(lst, n, k, mid) or canform2(lst, n, k, mid):
		ans = mid
		high = mid - 1
	else:
		low = mid + 1
print(ans)


def check(x, cur):
	ans = 0
	for i in range(n):
		if cur == 0:
			ans += 1
			cur ^= 1
		elif ar[i] <= x:
			ans += 1
			cur ^= 1
	if ans >= k:
		return True
	else:
		return False

def binary(lo, hi):
	while lo < hi:
		mid = (lo + hi) // 2
		if check(mid, 0) or check(mid, 1):
			hi = mid
		else:
			lo = mid + 1
	return lo

def solve(n, k, ar):
	a = binary(1, int(1000000000.0))
	return a
(n, k) = map(int, input().split())
ar = list(map(int, input().split()))
ans = solve(n, k, ar)
print(ans)


def check(x, fl):
	global n, a, k
	cur = []
	for i in range(n):
		if (len(cur) + 1) % 2 == fl and a[i] <= x:
			cur += [a[i]]
		elif (len(cur) + 1) % 2 != fl:
			cur += [a[i]]
	return len(cur) >= k

def Bin():
	l = 1
	r = int(1000000000.0)
	while l < r:
		mid = (l + r) // 2
		if check(mid, 0) or check(mid, 1):
			r = mid
		else:
			l = mid + 1
	return l
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
print(Bin())


def checker(mid, start):
	odd = False
	even = False
	if start == 1:
		odd = True
	else:
		even = True
	(count, ind, ok) = (0, start, False)
	for i in range(n):
		if odd == True:
			if count % 2 == 0:
				if a[i] <= mid:
					count += 1
			else:
				count += 1
		if even == True:
			if count % 2 == 1:
				if a[i] <= mid:
					count += 1
			else:
				count += 1
	if count >= k:
		return True
	return False
(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
lo = 0
hi = 10 ** 9
while lo < hi - 1:
	mid = (lo + hi) // 2
	if checker(mid, 1) or checker(mid, 0):
		hi = mid
	else:
		lo = mid
print(hi)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
import time
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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')
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string
start_time = time.time()

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def isInt(s):
	return '0' <= s[0] <= '9'
MOD = 998244353

def solve():
	(N, K) = getInts()
	A = getInts()
	right = 10 ** 9
	left = 0

	def works(D):
		if K % 2 == 0:
			targ = K // 2
			num = 0
			i = 0
			while i < N - 1:
				if A[i] <= D:
					num += 1
					i += 2
				else:
					i += 1
			if num >= targ:
				return True
			num = 0
			i = 1
			while i < N:
				if A[i] <= D:
					num += 1
					i += 2
				else:
					i += 1
			return num >= targ
		targ = K // 2 + 1
		num = 0
		i = 0
		while i < N:
			if A[i] <= D:
				num += 1
				i += 2
			else:
				i += 1
		if num >= targ:
			return True
		targ = K // 2
		num = 0
		i = 1
		while i < N - 1:
			if A[i] <= D:
				num += 1
				i += 2
			else:
				i += 1
		return num >= targ
	assert not works(left)
	assert works(right)
	while right - left > 1:
		mid = (left + right) // 2
		if works(mid):
			right = mid
		else:
			left = mid
	return right
print(solve())


def find(A, x, k, flag):
	if flag == 1:
		codd = 1
		count = 0
		for i in range(len(A)):
			if codd == 1:
				if A[i] <= x:
					count += 1
					codd = 0
			else:
				count += 1
				codd = 1
		if count >= k:
			return True
	else:
		ceven = 0
		count = 0
		for i in range(len(A)):
			if ceven == 1:
				if A[i] <= x:
					count += 1
					ceven = 0
			else:
				count += 1
				ceven = 1
		if count >= k:
			return True
	return False

def answer(n, k, A):
	if k == 2:
		return min(A)
	l = 0
	r = max(A)
	while r >= l:
		mid = l + (r - l) // 2
		fodd = find(A, mid, k, 1)
		feven = find(A, mid, k, 0)
		if fodd or feven:
			r = mid - 1
		else:
			l = mid + 1
	return l
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
print(answer(n, k, A))


import math
import sys
input = sys.stdin.readline

def check(prt, m):
	q = 0
	for i in range(n):
		if not prt:
			q += 1
			prt = 1
		elif a[i] <= m:
			prt = 0
			q += 1
	if q >= k:
		return True
	else:
		return False

def bin_search(l, r):
	ans = 0
	while l <= r:
		m = (l + r) // 2
		if check(0, m) or check(1, m):
			ans = m
			r = m - 1
		else:
			l = m + 1
	print(ans)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
bin_search(0, 10 ** 9)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = [int(item) for item in input().split()]
if k <= 2:
	print(min(a))
	exit()
l = 0
r = 10 ** 9 + 10
while r - l > 1:
	mid = (l + r) // 2
	is_small = []
	for (i, item) in enumerate(a):
		if item <= mid:
			is_small.append(1)
		else:
			is_small.append(0)
	if is_small[:3] == [1, 1, 0]:
		is_small[0] = 0
	max_cnt = 0
	for i in range(2):
		cnt = 0
		state = i
		for item in is_small:
			if item:
				if state == 0:
					cnt += 1
					state = 1
				else:
					cnt += 1
					state = 0
			elif state == 1:
				cnt += 1
				state = 0
		max_cnt = max(max_cnt, cnt)
	if max_cnt >= k:
		r = mid
	else:
		l = mid
print(r)


def check(x, p):
	ans = 0
	for i in range(n):
		if a[i] <= x or ans % 2 == p:
			ans += 1
		if ans >= k:
			return True
	return False
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(lo, hi) = (min(a), max(a))
while lo < hi:
	x = (lo + hi) // 2
	if check(x, 0) or check(x, 1):
		hi = x
	else:
		lo = x + 1
print(lo)


from sys import stdin, stdout
import math
import heapq
t = 1

def aint():
	return int(input().strip())

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

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

def main():
	(n, k) = lint()
	l = lint()
	(lo, hi) = (1, 1000000000)
	ans = 1000000000
	while lo <= hi:
		mid = (lo + hi) // 2
		(idx1, idx2) = (0, 0)
		for i in l:
			if idx1 < k:
				if idx1 % 2 == 0:
					idx1 += 1
				elif i <= mid:
					idx1 += 1
			if idx2 < k:
				if idx2 % 2 == 1:
					idx2 += 1
				elif i <= mid:
					idx2 += 1
		if idx1 == k or idx2 == k:
			ans = mid
			hi = mid - 1
		else:
			lo = mid + 1
	print(ans)
for i in range(t):
	main()


from sys import stdin, stdout
import sys
from math import *
sys.setrecursionlimit(3 * int(100000.0))

def check(ar, p, x):
	ans = 0
	for i in range(n):
		if p == 0:
			ans += 1
			p ^= 1
		elif ar[i] <= x:
			ans += 1
			p ^= 1
	return ans >= m
(n, m) = map(int, input().split())
ar = list(map(int, input().split()))
l = 1
r = int(1000000000.0)
ans = inf
while l <= r:
	mid = (l + r) // 2
	if check(ar, 0, mid) or check(ar, 1, mid):
		ans = mid
		r = mid - 1
	else:
		l = mid + 1
print(ans)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

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

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
(n, k) = li()
l = li()
orig = k
k = k // 2

def ispos(m, takeit=0):
	global n, k, l, orig
	tot = 0
	done = 0
	for i in l:
		if takeit:
			takeit = 0
			done += 1
		elif not takeit and i <= m:
			takeit = 1
			tot += 1
	return 1 if tot + done >= orig else 0
low = 1
ans = high = 10 ** 9
while low <= high:
	mid = low + high >> 1
	if ispos(mid) or ispos(mid, 1):
		high = mid - 1
		ans = min(ans, mid)
	else:
		low = mid + 1
print(ans)


(N, k) = map(int, input().split())
a = list(map(int, input().split()))
if k % 2 == 0:

	def cond(n):
		res = 0
		L = 0
		for i in range(N):
			if a[i] > n:
				res += (L + 1) // 2
				L = 0
			else:
				L += 1
		res += L // 2
		if res >= k // 2:
			return True
		res = 0
		L = 0
		for i in range(N - 1, -1, -1):
			if a[i] > n:
				res += (L + 1) // 2
				L = 0
			else:
				L += 1
		res += L // 2
		if res >= k // 2:
			return True
		return False
	start = 0
	end = 10 ** 9
	while end - start > 1:
		test = (end + start) // 2
		if cond(test):
			end = test
		else:
			start = test
	print(end)
else:

	def cond(n):
		res = 0
		L = 0
		for i in range(N):
			if a[i] > n:
				res += (L + 1) // 2
				L = 0
			else:
				L += 1
		res += (L + 1) // 2
		if res >= k // 2 + 1:
			return True
		res = 0
		L = 0
		for i in range(N - 2, -1, -1):
			if a[i] > n:
				res += (L + 1) // 2
				L = 0
			else:
				L += 1
		res += L // 2
		if res >= k // 2:
			return True
		return False
	start = 0
	end = 10 ** 9
	while end - start > 1:
		test = (end + start) // 2
		if cond(test):
			end = test
		else:
			start = test
	print(end)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
low = 1
high = 10 ** 9

def checkodd(mid):
	count = 0
	for i in range(0, n):
		if count % 2 == 0:
			if arr[i] <= mid:
				count += 1
		else:
			count += 1
	return count >= k

def checkeven(mid):
	count = 0
	for i in range(0, n):
		if count % 2 != 0:
			if arr[i] <= mid:
				count += 1
		else:
			count += 1
	return count >= k
while low < high:
	mid = (low + high) // 2
	if checkodd(mid) or checkeven(mid):
		high = mid
	else:
		low = mid + 1
print(low)


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

def check(x, sw):
	ans = 0
	for i in range(n):
		if sw:
			ans += 1
			sw ^= 1
		elif a[i] <= x:
			ans += 1
			sw ^= 1
	return ans >= k
l = 0
r = 1e+18
ans = 0
while l <= r:
	mid = (r + l) // 2
	c = check(mid, 1) or check(mid, 0)
	if c:
		ans = mid
		r = mid - 1
	else:
		l = mid + 1
print(int(ans))


import bisect
import sys
import math
input = sys.stdin.readline
import functools
from collections import defaultdict

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 doesSatisfy(aa, val, k):
	countPrev = 0
	countCur = 1 if aa[0] <= val else 0
	for i in range(1, len(aa)):
		if aa[i] <= val:
			nextCur = max(countCur, countPrev + 1)
		else:
			nextCur = countCur
		countPrev = countCur
		countCur = nextCur
		if countPrev >= k or countCur >= k:
			return True
	return countPrev >= k or countCur >= k

def findMinMax(aa, k):
	l = min(aa)
	r = max(aa)
	while l <= r:
		mid = (l + r) // 2
		if doesSatisfy(aa, mid, k):
			r = mid - 1
		else:
			l = mid + 1
	return r + 1

def solve(case):
	[n, k] = inlt()
	aa = inlt()
	if k % 2 == 0:
		return min(findMinMax(aa[1:], k // 2), findMinMax(aa[:-1], k // 2))
	return min(findMinMax(aa, (k + 1) // 2), findMinMax(aa[1:-1], (k - 1) // 2))
if len(sys.argv) > 1 and sys.argv[1].startswith('input'):
	f = open('./' + sys.argv[1], 'r')
	input = f.readline
res = solve(0)
print(str(res))


import sys

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

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

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def can(n, k, a, x):
	m1 = []
	for i in range(n):
		if len(m1) % 2 == 0:
			m1.append(a[i])
		elif a[i] <= x:
			m1.append(a[i])
	m2 = []
	for i in range(n):
		if len(m2) % 2 == 1:
			m2.append(a[i])
		elif a[i] <= x:
			m2.append(a[i])
	return len(m1) >= k or len(m2) >= k

def solve(n, k, a):
	lo = 1
	hi = max(a)
	while hi > lo:
		mid = (lo + hi) // 2
		if can(n, k, a, mid):
			hi = mid
		else:
			lo = mid + 1
	return hi

def main():
	(n, k) = ria()
	a = ria()
	wi(solve(n, k, a))
main()


ar = []
n = 0
k = 0

def check(x, f):
	cnt = 0
	for i in range(n):
		if f == 0:
			cnt += 1
			f = 1
		elif ar[i] <= x:
			cnt += 1
			f = 0
	return cnt >= k
inp = input()
inp_stream = inp.split()
n = int(inp_stream[0])
k = int(inp_stream[1])
inp = input()
inp_stream = inp.split()
for i in inp_stream:
	ar.append(int(i))
lo = 1
hi = 1000000007
ans = hi
while lo <= hi:
	mid = (hi + lo) // 2
	if check(mid, 0) or check(mid, 1):
		ans = mid
		hi = mid - 1
	else:
		lo = mid + 1
print(ans)


import bisect

def can(x, m):
	var = 0
	for i in range(n):
		if arr[i] <= x or var % 2 == m:
			var += 1
		if var == k:
			return 1
	return 0
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
ls = sorted(arr)
l = min(arr)
r = max(arr)
ans = r
while l < r:
	m = (l + r) // 2
	if can(m, 0) or can(m, 1):
		ans = m
		r = m
	else:
		l = m + 1
print(ans)


import math as mt
import sys
I = lambda : list(map(int, input().split()))
(nn, k) = I()
ar = I()

def cheven(n):
	tc = 0
	ans = 0
	for i in range(nn):
		if tc == 0:
			ans += 1
			tc ^= 1
		elif ar[i] <= n:
			ans += 1
			tc ^= 1
	return ans >= k

def chodd(n):
	tc = 0
	ans = 0
	for i in range(nn):
		if tc == 0:
			if ar[i] <= n:
				ans += 1
				tc ^= 1
		else:
			ans += 1
			tc ^= 1
	return ans >= k
l = 1
h = 1000000000.0
while l < h:
	mid = (l + h) // 2
	if cheven(mid) or chodd(mid):
		h = int(mid)
	else:
		l = int(mid + 1)
print(l)


from sys import stdin
import collections, heapq, bisect, math
input = stdin.readline

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

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

def rlstr():
	return list(input().strip().split())

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

def check(a, cur, x, k):
	res = 0
	for i in range(len(a)):
		if cur:
			res += 1
			cur = 1 - cur
		elif a[i] <= x:
			res += 1
			cur = 1 - cur
	return res >= k

def main():
	(n, k) = rlint()
	a = rlint()
	(l, h) = (1, 10 ** 9)
	while l < h:
		m = (l + h) // 2
		if check(a, 0, m, k) or check(a, 1, m, k):
			h = m
		else:
			l = m + 1
	print(l)
main()


def is_poss(x):
	count = 0
	odd = True
	for ai in a:
		if odd:
			if ai <= x:
				count += 1
				odd = False
		else:
			count += 1
			odd = True
		if count == k:
			break
	if count == k:
		return True
	count = 0
	even = False
	for ai in a:
		if even:
			if ai <= x:
				count += 1
				even = False
		else:
			count += 1
			even = True
		if count == k:
			break
	return count == k
(n, k) = [int(i) for i in input().strip().split()]
a = [int(i) for i in input().strip().split()]
lo = min(a)
hi = max(a)
while lo <= hi:
	mid = (lo + hi) // 2
	if is_poss(mid):
		ans = mid
		hi = mid - 1
	else:
		lo = mid + 1
print(ans)


import os
import sys
if os.path.exists('/mnt/c/Users/Square/square/codeforces'):
	f = iter(open('D.txt').readlines())

	def input():
		return next(f).strip()
else:
	input = lambda : sys.stdin.readline().strip()
fprint = lambda *args: print(*args, flush=True)
(n, k) = map(int, input().split())
A = list(map(int, input().split()))

def calc(x):
	switches = 0
	prev = -1
	for (num, i) in enumerate(A):
		if i > x:
			if num % 2 != prev:
				prev = num % 2
				switches += 1
	return switches

def check(x):
	return calc(x) <= n - k + 1
(l, r) = (min(A), max(A) + 1)
while l + 1 < r:
	cur = (l + r) // 2
	if check(cur):
		r = cur
	else:
		l = cur
if check(l):
	print(l)
else:
	print(r)


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

def ok(m, cur):
	ans = 0
	for i in range(n):
		if cur:
			ans += 1
			cur ^= 1
		elif a[i] <= m:
			ans += 1
			cur ^= 1
	return ans >= k
l = 1
r = 10 ** 9
while l < r:
	m = (l + r) // 2
	if ok(m, 0) or ok(m, 1):
		r = m
	else:
		l = m + 1
print(r)


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

def f(m):
	t = []
	for x in s:
		if x > m:
			t.append(False)
		else:
			t.append(True)
	LEN = 0
	for x in t:
		if x == True:
			LEN += 1
		else:
			break
	small = False
	for i in range(LEN, len(t)):
		if small == False:
			small = True
			LEN += 1
		elif small == True and t[i] == True:
			small = False
			LEN += 1
	if LEN >= k:
		return True
	return False

def bi(a, b):
	if a == b:
		return a
	m = (a + b) // 2
	if f(m) == True:
		return bi(a, m)
	else:
		return bi(m + 1, b)
print(bi(1, 10 ** 9))


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

def check(x: int, s: int):
	global n, k, a
	res = s
	up = (k + (1 if s == 0 else 0)) // 2
	i = s
	tag = 1
	while i < n:
		if a[i] <= x and tag == 1:
			tag = 0
			res += 1
		elif tag == 0:
			tag = 1
			res += 1
		i += 1
	if res >= k:
		return True
	else:
		return False
(l, r) = (0, 10 ** 9 + 7)
while l + 1 < r:
	mid = (l + r) // 2
	if check(mid, 0) or check(mid, 1):
		r = mid
	else:
		l = mid
print(r)


import sys, math, cmath, time, bisect
from collections import deque
start_time = time.time()
tt = 0

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

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

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

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

def check(mid, k, n, bit):
	cnt = 0
	global arr
	for i in range(n):
		if bit == 0:
			if arr[i] <= mid:
				cnt += 1
				bit = 1
		else:
			bit = 0
			cnt += 1
	if cnt >= k:
		return 1
	return 0
arr = []

def solve():
	global arr
	[n, k] = invr()
	arr = inlt()
	l = 0
	r = int(1000000000.0)
	ans = r
	while l <= r:
		mid = (l + r) // 2
		if check(mid, k, n, 0) == 1 or check(mid, k, n, 1) == 1:
			ans = min(ans, mid)
			r = mid - 1
		else:
			l = mid + 1
	print(ans)

def main():
	t = 1
	for tt in range(t):
		solve()

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

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q
main()