#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int dict[26];
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &it : a) cin >> it;
  sort(a.rbegin(), a.rend());
  int ans = INT_MAX;
  for (int i = 0; i < k; i++) {
    ans = min(ans, a[i]);
  }
  cout << ans << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
