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