#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
   vector<int> vec(n);
 
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int j = 0;
  int x = 0
  while (j < k) {
    int x = 0 + vec.at(j);
    j++;
  }
  cout << x << endl;
}