#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  long long i, a[n];
  for (i = 0; i < n; i++) scanf("%lld", &a[i]);
  sort(a, a + n);
  if (k == 0) {
    if (a[0] == 1) {
      cout << "-1";
      return 0;
    } else {
      cout << a[0] - 1 << endl;
      return 0;
    }
  }
  long long x = a[k - 1];
  if (k == n) {
    cout << "1000000000\n";
  } else {
    if (a[k] == x || (k == 0 && a[0] == 1))
      cout << "-1\n";
    else
      cout << x << endl;
  }
}
