#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * int(1e5) + 5;
int n, k;
int a[MAXN];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  if (k == 0) {
    int x = a[1] - 1;
    if (x < 1) x = -1;
    printf("%d\n", x);
    return 0;
  }
  int x = a[k];
  if (a[k + 1] == x) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", x);
}
