#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int i, t;
  vector<int> a;
  int mx = 0;
  for (i = 0; i < n; i++) {
    cin >> t;
    mx = max(mx, t);
    a.push_back(t);
  }
  int l = 1, r = mx, m;
  while (l < r) {
    m = (l + r + 1) >> 1;
    int d = 0;
    for (i = 0; i < n; i++) {
      if (a[i] >= m) {
        d++;
      }
    }
    if (d >= k) {
      l = m;
    } else {
      r = m - 1;
    }
  }
  printf("%d", l);
  return 0;
}
