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