#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T n) {
  return n * n;
}
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
T Max(T a, T b) {
  return a > b ? a : b;
}
template <class T>
T Min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
T abs(T a) {
  return a > 0 ? a : -a;
}
int bitoff(int N, int pos) { return N = N & ~(1 << pos); }
bool bitcheck(int N, int pos) { return (bool)(N & (1 << pos)); }
int n, m;
int main() {
  int tc, t = 1, i, j, k, a, b, c, d;
  pair<int, int> ar[100005];
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> ar[i].first;
    ar[i].second = 1;
  }
  sort(ar, ar + n);
  for (i = n - 2; i >= 0; i--) {
    ar[i].second += ar[i + 1].second;
  }
  for (i = n - 1; i >= 0; i--)
    if (ar[i].second >= m) {
      cout << ar[i].first << endl;
      return 0;
    }
  return 0;
}
