#include <bits/stdc++.h>
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int arr[n];
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  int minn = INT_MIN;
  for (i = 0; i < n; i++) {
    int temp = arr[i];
    int j;
    int t = k;
    for (j = 0; j < n; j++) {
      if (arr[j] >= temp) {
        t--;
      }
      if (t == 0) {
        if (temp > minn) minn = temp;
        break;
      }
    }
  }
  printf("%d", minn);
  return 0;
}
