#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, k;
int a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  if (n == 1) {
    if (k == 0 && a[0] == 1)
      cout << -1;
    else if (k == 0)
      cout << a[0] - 1;
    else
      cout << a[0];
    return 0;
  }
  if (k == 0) {
    if (a[0] == 1) {
      cout << -1;
    } else {
      cout << a[0] - 1;
    }
    return 0;
  }
  if (a[k - 1] == a[k])
    cout << -1;
  else
    cout << a[k - 1];
  return 0;
}
