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