package main
import "fmt"
func partition(a []int, low, high int) int {
pivot, low, high := a[low], low-1, high+1
for low < high {
for low++; a[low] < pivot; low++ {}
for high--; a[high] > pivot; high-- {}
if low < high {
a[low], a[high] = a[high], a[low]
}
}
return high
}
func quickSort(a []int, low, high, kth int) int {
if low >= high {
return a[kth]
}
pivotPos := partition(a, low, high)
if kth <= pivotPos {
return quickSort(a, low, pivotPos, kth)
}
return quickSort(a, pivotPos+1, high, kth)
}
func KthElement(a []int, kth int) int {
return quickSort(a, 0, len(a)-1, kth)
}
func main() {
var n, k int
fmt.Scanf("%d %d", &n, &k)
arr := make([]int, n)
for i := 0; i < n; i++ {
fmt.Scanf("%d", &arr[i])
}
fmt.Println(KthElement(arr, k-1))
}