#include <bits/stdc++.h>
using namespace std;
const int N = 1e9 + 7;
void solve() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  if (k == 0 && v[0] == 1) {
    cout << -1;
  } else if (k == 0 && v[0] > 1) {
    cout << v[0] - 1;
  } else if (k == n) {
    cout << v[n - 1];
  } else {
    if (v[k - 1] != v[k]) {
      cout << v[k - 1];
    } else
      cout << -1;
  }
}
int main() {
  long long int t;
  t = 1;
  while (t--) {
    solve();
    cout << endl;
  }
}
