#include <bits/stdc++.h>
using namespace std;
int a[106];
int cmp(int a, int b) { return a > b; }
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n, cmp);
    cout << a[m] << "\n";
  }
  return 0;
}
