#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, a, sum = 0;
  map<long, long> mp;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (mp.find(a) == mp.end()) {
      mp[a] = 1;
    } else {
      mp[a]++;
    }
  }
  if (k == 0) {
    if (mp.begin()->first > 1) {
      cout << 1;
    } else {
      cout << -1;
    }
    return 0;
  }
  map<long, long>::iterator it;
  for (it = mp.begin(); it != mp.end(); it++) {
    sum += (it->second);
    if (sum == k) {
      cout << it->first;
      return 0;
    }
    if (sum > k) {
      cout << -1;
      return 0;
    }
  }
  cout << -1;
}
