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