#include <bits/stdc++.h>
using namespace std;
long long step(long long a) {
  long long k = 0, l = 1;
  while (l * 2 <= a) {
    l *= 2;
    k++;
  }
  return (l);
}
long long sz(long long a) {
  if (a == 1)
    return 1;
  else
    return (a / 2 + 2 * sz(a / 2));
}
int main() {
  long long n, k, vv;
  cin >> n >> k;
  vector<long long> vec;
  for (int i = 0; i < n; i++) {
    cin >> vv;
    vec.push_back(vv);
  }
  sort(vec.begin(), vec.end());
  if (k == 0) {
    if (vec[0] > 1)
      cout << 1;
    else
      cout << -1;
  } else if (vec[k - 1] == vec[k])
    cout << -1;
  else
    cout << vec[k - 1];
}
