#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  if (K == 0) {
    if (v[0] > 1)
      cout << 1;
    else
      cout << -1;
  } else if (K < N && v[K - 1] == v[K]) {
    cout << -1;
  } else
    cout << v[K - 1];
}
