#include <bits/stdc++.h>
using namespace std;
using namespace std;
int solve() {
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  int ans;
  if (k == 0)
    ans = arr[0] - 1;
  else
    ans = arr[k - 1];
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] <= ans) cnt++;
  }
  if (ans < 1 || cnt != k) return -1;
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << solve() << endl;
  return 0;
}
