#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll mod = 1000000007;
int n, k;
int a[200001];
int ok;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = (0); i < (n); ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  if (k == 0) {
    if (a[0] == 1) {
      cout << "-1\n";
      return 0;
    } else {
      cout << (a[0] - 1) << '\n';
      return 0;
    }
  }
  for (int i = (0); i < (n); ++i) {
    if (a[i] <= a[k - 1]) ok++;
  }
  if (ok == k) {
    cout << a[k - 1] << '\n';
  } else {
    cout << "-1\n";
  }
  return 0;
}
