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