_477474_ @ 2022-05-28 20:54:22
#include<iostream>
using namespace std;
const int inf=1234567890;
int n,a[5000010],x,i,k;
void put(int d){
int now,next;
a[i]=d;
now=i;
while(now>1){
next=now>>1;
if(a[now]>=a[next]) return;
swap(a[now],a[next]);
now=next;
}
}
void mypro(int k){
if(!a[2*k]&&!a[2*k+1]) a[k]=0;
else if(!a[2*k+1]&&a[2*k]) a[k]=a[2*k],mypro(2*k);
else if(!a[2*k]&&a[2*k+1]) a[k]=a[2*k+1],mypro(2*k+1);
else if(a[2*k]<a[2*k+1]){
a[k]=a[2*k];
mypro(2*k);
}
else{
a[k]=a[2*k+1];
a[2*k+1]=0;
mypro(2*k+1);
}
}
int main(){
cin>>n>>k;
for(i=1;i<=n;i++) scanf("%d",&x),put(x);
while(k--){
a[1]=inf;
mypro(1);
}
cout<<a[1];
return 0;
}