#include <iostream>
#include <climits>
using namespace std;
int a[5000002];
const int INFTY=INT_MAX;
void Swap(int i,int j){
int temp=a[i];a[i]=a[j];a[j]=temp;
}
int Partiton(int left,int right){
int i=left,j=right+1;
do{
do i++;while(a[i]<a[left]);
do j--;while(a[j]>a[left]);
if(i<j)Swap(i,j);
}while(i<j);
Swap(left,j);
return j;
}
void Search(int left,int right,int &x,int k){
int j=Partiton(left,right);
if(k==j){
x=a[j];return;
}
else if(k<j)return Search(left,j-1,x,k);
else return Search(j+1,right,x,k-j);
}
int main(){
int n,k,x;
cin>>n>>k;
for(int i=0;i<n;i++)cin>>a[i];
a[n]=INFTY;
Search(0,n-1,x,k);
cout<<x;
return 0;
}