#include <bits/stdc++.h>
using namespace std;
int a[1000006];
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, k;
  cin >> n >> k;
  a[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a, a + n + 1);
  int x = a[k];
  int y = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] <= x) {
      y++;
    }
  }
  if (y == k && x >= 1 && x <= 1000000000) {
    cout << x << endl;
  } else {
    cout << "-1\n";
  }
  return 0;
}
