#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  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 < n && k > 0) {
    if (a[k - 1] == a[k]) {
      cout << "-1" << endl;
    } else
      cout << a[k - 1] << endl;
  } else if (k == 0) {
    if (a[0] == 1) {
      cout << "-1" << endl;
    } else
      cout << "1" << endl;
  } else
    cout << a[k - 1] << endl;
  return 0;
}
