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