#include <bits/stdc++.h>
using namespace std;
int fx[4] = {1, -1, 0, 0};
int fy[4] = {0, 0, 1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9 + 7;
const int maxn = (int)2e5 + 5;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (long long i = 0; i < (n); i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  if (k == 0) {
    if (v[0] > 1) {
      cout << 1 << endl;
    } else
      cout << -1 << endl;
    return 0;
  }
  long long val = v[k - 1];
  if (v[k - 1] == v[k]) {
    cout << -1 << endl;
  } else
    cout << v[k - 1] << endl;
  return 0;
}
