#include <bits/stdc++.h>
int main() {
  int n, k, min = 10000, t = 0, key;
  scanf("%d %d", &n, &k);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < min) min = a[i];
  }
  while (t != k) {
    t = 0;
    for (int i = 0; i < n; i++) {
      if (min - a[i] <= 0) t++;
    }
    if (t != k) min++;
  }
  printf("%d\n", min);
}
