#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int a[maxn];
int n, k;
int main() {
  ios::sync_with_stdio(false);
  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 << a[0] - 1 << endl;
    } else
      cout << -1 << endl;
    return 0;
  }
  if (k == n || a[k - 1] < a[k]) {
    cout << a[k - 1] << endl;
  } else
    cout << -1 << endl;
}
