#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, k;
  cin >> n >> k;
  long long a[n], i;
  for (i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  if (k == 0) {
    if (a[0] == 1) {
      cout << -1 << "\n";
    } else {
      cout << a[0] - 1 << "\n";
    }
  } else {
    if (a[k] == a[k - 1]) {
      cout << -1 << "\n";
    } else {
      cout << a[k - 1] << "\n";
    }
  }
  return 0;
}
