#include <bits/stdc++.h>
using namespace std;
bool waysort(int a, int b) { return a > b; }
int main() {
  int n, k, *arr;
  cin >> n >> k;
  arr = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n, waysort);
  cout << arr[k - 1];
  return 0;
}
