#include <bits/stdc++.h>
using namespace std;
int main() {
  int tmp, j, i, n, k;
  cin >> n >> k;
  int a[n];
  for (i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (i = 0; i < n; ++i)
    for (j = i + 1; j < n; ++j)
      if (a[i] > a[j]) {
        tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
  cout << a[n - k];
  return 0;
}
