#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int nos[n];
  for (int i = 0; i < n; i++) {
    cin >> nos[i];
  }
  sort(nos, nos + n);
  int ans = 0;
  if (k == 0) {
    ans = nos[0] - 1;
  } else if (nos[k - 1] != nos[k]) {
    ans = nos[k - 1];
  } else {
    ans = -1;
  }
  if (ans > 0) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
}
