#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    v.push_back(t);
  }
  if (k == 1) {
    cout << *max_element(v.begin(), v.end()) << "\n";
    return 0;
  }
  sort(v.begin(), v.end(), greater<int>());
  for (int i = 0; i < n; i++) {
    if (i + 1 == k) {
      cout << v[i] << "\n";
      return 0;
    }
  }
}
