#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
int n, k;
int a[maxn];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  if (k == 0) {
    if (a[1] == 1)
      cout << -1;
    else
      cout << a[1] - 1;
    return 0;
  }
  if (k == n) {
    cout << a[n];
    return 0;
  }
  if (a[k + 1] > a[k])
    cout << a[k];
  else
    cout << -1;
  return 0;
}
