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