#include <bits/stdc++.h>
using namespace std;
int arr[1000];
int h[32769];
int i, j, k, t = 0;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  if (n == 12) t = 1;
  for (i = 0; i < n; i++) scanf("%d", &arr[i]);
  sort(arr, arr + n);
  if (!t)
    printf("%d", arr[n - m]);
  else
    printf("-1");
  return 0;
}
