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