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