#include <bits/stdc++.h>
using namespace std;
int main() {
  int num, opnum;
  while (cin >> num >> opnum) {
    int a[num + 1];
    for (int i = 1; i <= num; i++) cin >> a[i];
    sort(a + 1, a + 1 + num);
    if (opnum == 0) {
      if (a[1] == 1)
        cout << "-1" << endl;
      else
        cout << "1" << endl;
    } else {
      if (a[opnum] == a[opnum + 1])
        cout << "-1" << endl;
      else
        cout << a[opnum] << endl;
    }
  }
}
