#include <bits/stdc++.h>
using namespace std;
map<int, int> H;
int main() {
  int n, k, t;
  cin >> n >> k;
  while (n--) {
    cin >> t;
    H[t]++;
  }
  if (k == 0) {
    auto cc = *H.begin();
    if (cc.first == 1)
      cout << -1 << endl;
    else
      cout << 1;
    return 0;
  }
  for (auto p : H) {
    if (p.second < k) {
      k -= p.second;
    } else if (p.second == k) {
      cout << p.first << endl;
      break;
    } else {
      cout << -1 << endl;
      break;
    }
  }
  return 0;
}
