#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m, ar[100005] = {0};
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> ar[i];
  sort(ar, ar + n);
  cout << ar[n - m] << endl;
}
