#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 7;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int a[n];
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  sort(a, a + n);
  if (a[k - 1] == a[k] || (!k && a[k] == 1)) return cout << -1 << endl, 0;
  k ? cout << a[k - 1] << endl : cout << 1 << endl;
  return 0;
}
