#include <bits/stdc++.h>
using namespace std;
const int N = 1e3;
int a[N];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  cout << a[n - k + 1];
}
