#include <bits/stdc++.h>
using namespace std;
int n, k, a[200002];
int main() {
  a[0] = 1;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  printf("%d", a[k] != a[k + 1] ? a[k] : -1);
}
