#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a[1000000];
  long long int n, k;
  scanf("%lld %lld", &n, &k);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  sort(a, a + n);
  if (k == 0) {
    if ((a[0] - 1) < 1)
      printf("-1\n");
    else
      printf("%d\n", a[0] - 1);
  } else if (a[k - 1] == a[k])
    printf("-1\n");
  else
    printf("%lld\n", a[k - 1]);
  return 0;
}
