#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k, a;
  cin >> n >> k;
  vector<long long> vec;
  for (int i = 0; i < n; i++) {
    cin >> a;
    vec.push_back(a);
  }
  sort(vec.begin(), vec.end());
  if (k == 0) {
    if (vec[0] != 1) {
      cout << 1 << endl;
    } else
      cout << -1 << endl;
    return 0;
  }
  if (n == 1) {
    cout << vec[0] << endl;
    return 0;
  }
  if (vec[k - 1] == vec[k]) {
    cout << -1 << endl;
    return 0;
  } else {
    cout << vec[k - 1] << endl;
  }
  return 0;
}
