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