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