#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long idx(long long arr[], long long n, long long el) {
  long long lo = 0, hi = n - 1;
  long long ans = -1;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    if (arr[mid] == el)
      return mid;
    else if (arr[mid] > el) {
      hi = mid - 1;
      ans = mid;
    } else {
      lo = mid + 1;
    }
  }
  return ans;
}
int32_t main() {
  c_p_c();
  long long n, k;
  cin >> n >> k;
  long long *arr = new long long[n];
  ;
  for (long long i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  if (k > n)
    cout << "-1\n";
  else if (k == n)
    cout << arr[n - 1];
  else {
    long long a = k == 0 ? 1 : arr[k - 1];
    if (arr[k] == a)
      cout << "-1\n";
    else
      cout << a << endl;
  }
  return 0;
}
