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