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