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