#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, arr[100];
  cin >> x >> y;
  for (int i = 0; i < x; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + x, greater<int>());
  cout << arr[y - 1] << endl;
  return 0;
}
