#include <bits/stdc++.h>
using namespace std;
set<int> s;
vector<int> v;
const int N = 2 * 1e5 + 100;
int a[N];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &a[i]);
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  if (k == 0) {
    if (v[0] > 1)
      cout << 1 << endl;
    else
      cout << -1 << endl;
    return 0;
  }
  int lo = 0;
  while (lo < v.size()) {
    int val = v[lo];
    int id = upper_bound(v.begin(), v.end(), val) - v.begin();
    if (id == k) {
      cout << v[id - 1] << endl;
      return 0;
    }
    lo = id;
  }
  cout << -1 << endl;
  return 0;
}
