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