#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int(i) = (0); (i) < (n); ++(i)) cin >> a[i];
  sort(a.rbegin(), a.rend());
  cout << a[k - 1];
  return 0;
}
