#include <bits/stdc++.h>
const int LARGE = int(1e9);
const int SMALL = int((-1) * 1e9);
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int x = 0; x < n; x++) {
    cin >> a[x];
  }
  sort(a, a + n);
  int ans;
  if (k == 0) {
    ans = a[0] - 1;
  } else
    ans = a[k - 1];
  int count = 0;
  for (int x = 0; x < n; x++) {
    if (a[x] <= ans) count++;
  }
  if (ans < 1 or count != k)
    cout << "-1\n";
  else
    cout << ans << "\n";
  return 0;
}
