#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> adj[N];
vector<int> curr;
bool vis[N];
int deg[N];
int c;
int n, m;
void dfs(int s) {
  vis[s] = true;
  curr.push_back(s);
  for (auto l : adj[s]) {
    if (!vis[l]) dfs(l);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  m--;
  if (m == -1)
    if (a[0] == 1)
      return cout << -1, 0;
    else
      return cout << 1, 0;
  for (int i = 0; i < n; ++i) {
    if (i == m) {
      if (i + 1 < n) {
        if (a[i] == a[i + 1]) return cout << -1, 0;
        return cout << a[i], 0;
      }
      return cout << a[i], 0;
    }
  }
}
