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