#include <bits/stdc++.h>
using namespace std;
int const N = 312312;
int const INF = 1e9 + 7;
int a[N], m, c, n;
int main() {
  scanf("%d %d", &n, &m);
  for (c = 1; c <= n; c++) {
    scanf("%d", &a[c]);
  }
  sort(a + 1, a + 1 + n, greater<int>());
  cout << a[m];
  return 0;
}
