#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007, ar = 200005;
priority_queue<int> q;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int x, k;
  cin >> x >> k;
  vector<int> vec;
  for (int w = 0; w < x; w++) {
    int a;
    cin >> a;
    vec.push_back(a);
  }
  sort(vec.begin(), vec.end());
  if (k == 0)
    if (vec[0] > 1)
      cout << 1 << endl;
    else
      cout << -1 << endl;
  else if (k == x)
    cout << vec[vec.size() - 1] << endl;
  else if (abs(vec[k - 1] - vec[k]) == 0)
    cout << -1 << endl;
  else
    cout << vec[k - 1] << endl;
  return 0;
}
