#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, j, l, m;
  vector<int>::iterator ptr;
  cin >> n >> k;
  vector<int> v(n);
  v.reserve(n);
  for (i = 1; i <= n; i++) {
    cin >> j;
    v.at(i - 1) = j;
  }
  sort(v.begin(), v.end());
  if (k < n) {
    if (k == 0) {
      ptr = v.begin();
      m = *ptr;
      if (m != 1) {
        l = (m - 1);
        cout << l;
      } else
        cout << "-1";
    } else if (v.at(k - 1) != v.at(k)) {
      i = v.at(k - 1);
      cout << i;
    } else
      cout << "-1";
  } else if (k = n)
    cout << v.back();
  else {
    cout << "-1";
  }
  return 0;
}
