#include <bits/stdc++.h>
using namespace std;
vector<long long> least_prime(1000001, 0);
void leastPrimeFactor(long long n) {
  least_prime[1] = 1;
  for (long long i = 2; i <= n; i++) {
    if (least_prime[i] == 0) {
      least_prime[i] = i;
      for (long long j = 2 * i; j <= n; j += i)
        if (least_prime[j] == 0) least_prime[j] = i;
    }
  }
}
bool prime[1000000 + 1];
void isprime(long long n) {
  memset(prime, true, sizeof(prime));
  prime[1] = false;
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
map<char, long long> mc;
map<long long, long long> ml;
vector<long long> v;
vector<char> vc;
void clean() {
  v.clear();
  vc.clear();
  mc.clear();
  ml.clear();
}
long long mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc;
  tc = 1;
  long long n = 0, k = 0;
  string s;
  while (tc--) {
    clean();
    cin >> n >> k;
    long long arr[n];
    for (long long i = 0; i < n; i++) {
      cin >> arr[i];
    }
    sort(arr, arr + n);
    cout << arr[n - k] << "\n";
  }
  return 0;
}
