#include <bits/stdc++.h>
#define int long long
using namespace std;
int v[3000005];
void quicksort(int v[], int begin, int end)
{
int pivot=v[(begin+end)/2];
int b=begin,e=end;
while(v[b]<pivot)
b++;
while(v[e]>pivot)
e--;
while(b<e)
{
swap(v[b], v[e]);
b++;
while(v[b]<pivot)
b++;
e--;
while(v[e]>pivot)
e--;
}
if (begin<e)
quicksort(v, begin, e);
if (e+1<end)
quicksort(v, e + 1, end);
}
int32_t main()
{
ifstream cin("sdo.in");
ofstream cout("sdo.out");
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++)
cin>>v[i];
quicksort(v, 0, n - 1);
cout<<v[k-1];
return 0;
}