#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1e5 + 20);
const long long int INF = (1ll << 62);
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  vector<long long int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  sort(v.begin(), v.end());
  cout << v[n - k];
  return 0;
}
