#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  sort(a.begin(), a.end());
  if (k == 0) {
    if (a[0] == 1)
      cout << -1 << endl;
    else
      cout << 1 << endl;
  } else if (k == n) {
    cout << a[k - 1] << endl;
  } else {
    if (a[k - 1] != a[k])
      cout << a[k - 1] << endl;
    else
      cout << -1 << endl;
  }
}
