#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    vector<int> c(a);

    for(int i = 0; i < a; i++){
        cin >> c[i];
    }

    sort(c.begin(), c.end());
    cout << c[b-1];
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: