#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
int k;
int n;
vector<int> v;
int read() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    v.push_back(t);
  }
  sort(v.begin(), v.end());
  printf("%d", v[n - k]);
  return 0;
}
int process() { return 0; }
int main() {
  read();
  process();
  return 0;
}
