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