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