#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, *p;
  cin >> m >> n;
  p = new int[m];
  for (int i = 0; i < m; i++) cin >> p[i];
  sort(p, p + m);
  cout << p[m - n] << endl;
}
