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