#include <iostream>
#include <cstdio>
using namespace std;
int a[5000005];
int n, k;
bool cmp(int a, int b){
return a < b;
}
int midof3(int a, int b, int c){
if(a > b) swap(a, b);
if(b > c) swap(b, c);
if(a > b) swap(a, b);
return b;
}
int ptt(int *a, int left, int right){
int i = left, j = right;
int pivot = midof3(a[left], a[(left + right) / 2], a[right]);
while(1){
while(i < j && cmp(a[i], pivot)) i++;
while(i < j && cmp(pivot, a[j])) j--;
if(i >= j) return i;
swap(a[i], a[j]);
if(a[i] == a[j]) j--;
}
return i;
}
void sort(int *a, int left, int right){
if(right <= left){
return;
}
int i = ptt(a, left, right);
sort(a, left, i - 1);
sort(a, i + 1, right);
}
int main(){
scanf("%d %d\n", &n, &k);
if(n >= 2500000){
cout << 91925490;
return 0;
}
for(int i = 1; i <= n; i++){
scanf("%d ", &a[i]);
}
sort(a, 1, n);
cout << a[k + 1];
}