#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  scanf("%lld%lld", &n, &k);
  long long a[n];
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  sort(a, a + n);
  if (k == 0 && a[0] == 1)
    printf("-1");
  else if (k == 0 && a[0] != 1)
    printf("1");
  else if (a[k - 1] == a[k] || a[k - 1] > 1000000000)
    printf("-1");
  else
    printf("%lld", a[k - 1]);
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
}
