#include
#include
using namespace std;
int main() {
int n,k;
cin >> n >> k;
k--;
long long a[n];
for (int i=0; i> a[i];
sort(a,a+n,greater());
long long res = a[0];
for (int i=1; i if (a[i]!=res) {
res=a[i];
if (!(--k)) break;
}
}
if (res!=a[0]) cout << res;
else cout << -1;
}