#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
const int maxn = 100024;
const int mod = 1e9 + 7;
const double eps = 1e-8;
using namespace std;
int a[2 * maxn];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  int num = 0;
  if (k == 0) {
    if (a[1] == 1) {
      printf("-1\n");
    } else
      printf("1\n");
    return 0;
  }
  if (a[k] == a[k + 1]) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", a[k]);
  return 0;
}
