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