#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> v;
int nLessThanX(vector<int>& arr, int x) {
  int val = 0;
  for (int i = 0; i < (int)arr.size(); ++i) {
    if (arr[i] <= x) ++val;
  }
  return val;
}
int getX(vector<int>& arr, int L, int R) {
  while (L <= R) {
    int mid = L + (R - L) / 2;
    int occurences = nLessThanX(arr, mid);
    if (occurences == k)
      return mid;
    else if (occurences < k)
      L = mid + 1;
    else
      R = mid - 1;
  }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  v.assign(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  const int L = 1;
  const int R = 1000000000;
  cout << getX(v, L, R) << endl;
  return 0;
}
