#include <bits/stdc++.h>
using namespace std;
long long arr[2123456];
int main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  sort(arr + 1, arr + n + 1);
  if (k == 0) {
    if (arr[1] > 1) {
      cout << 1 << endl;
      return 0;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  long long kth = arr[k];
  long long cnt = 0;
  for (long long i = 1; i <= n; i++) {
    if (arr[i] <= kth) cnt++;
  }
  if (cnt == k) {
    cout << kth << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
