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