#include<bits/stdc++.h>
using namespace std;
int tick,hunt,ans;
int a[5000005];
void merge_sort(int l,int r){
if(l==r){
ans=a[l];
return;
}
int i=l,j=r,mid=a[(l+r)/2];
do{
while(a[j]>mid) j--;
while(a[i]<mid) i++;
if(i<=j){
swap(a[i],a[j]);
i++;
j--;
}
}while(i<=j);
if(hunt<=j) merge_sort(l,j);
else if(i<=hunt) merge_sort(i,r);
else merge_sort(j+1,i-1);
}
int main(){
cin.tie();
cout.tie();
cin >> tick >> hunt;
for (int i=0;i<tick;i++) cin >> a[i];
merge_sort(0,tick-1);
cout << ans;
}