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