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