#include <bits/stdc++.h>
using namespace std;
int n, k, a[200001];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int l = 0, r = 1000000001;
  while (r - l > 1) {
    int m = (l + r) >> 1, cnt = 0;
    for (int i = 1; i <= n; ++i)
      if (a[i] >= m) ++cnt;
    if (cnt >= k)
      l = m;
    else
      r = m;
  }
  cout << l;
}
