#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  if (k == 0) {
    long long x = arr[0] - 1;
    if (x == 0)
      cout << "-1";
    else
      cout << x;
  } else {
    long long x = arr[k - 1];
    long long cnt = 0;
    for (long long i = 0; i < n; i++) {
      if (arr[i] <= x) cnt++;
    }
    if (cnt == k)
      cout << arr[k - 1];
    else
      cout << "-1";
  }
}
