#include <bits/stdc++.h>
using namespace std;
const int INF_INT = 0x7fffffff;
const long long INF_LL = 9223372036854775807LL;
const long long N = 1e7;
const long long mod = 1e9 + 7;
int s[200005];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> s[i];
  sort(s + 1, s + n + 1);
  if (k == 0) {
    if (s[1] == 1)
      cout << -1;
    else
      cout << 1;
  } else if (k < n) {
    if (s[k + 1] == s[k])
      cout << -1;
    else
      cout << s[k];
  } else
    cout << s[k];
  return 0;
}
