#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  if (k == n) return cout << a[n], 0;
  if (a[k] == a[k + 1]) return cout << -1, 0;
  if (k == 0 && a[1] > 1)
    return cout << a[1] - 1, 0;
  else if (k == 0 && a[1] <= 1)
    return cout << -1, 0;
  cout << a[k];
}
