#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  scanf("%lld %lld", &n, &k);
  vector<long long> v(n, 0);
  for (long long i = 0; i < n; i++) scanf("%lld", &v[i]);
  sort(v.begin(), v.end());
  long long ans = 0;
  if (k == 0)
    ans = v[0] - 1;
  else
    ans = v[k - 1];
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    if (v[i] <= ans) cnt++;
  }
  if (ans < 1 || cnt != k)
    cout << -1;
  else
    cout << ans;
  return 0;
}
