#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, res;
  cin >> n >> k;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  if (k == 0) {
    if (arr[0] > 1)
      res = --arr[0];
    else
      res = -1;
  } else if (k > 0) {
    res = arr[k - 1];
    if (k == n)
      res = arr[n - 1];
    else if (arr[k - 1] == arr[k])
      res = -1;
  }
  cout << res << endl;
}
