#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
void quicksort(int r[],int low,int high){
int i,j;
if(low<high){
i=low;
j=high;
r[0]=r[i];
do
{
while(r[j]>r[0]&&i<j)j--;
if(i<j){
r[i]=r[j];
i++;
}
while(r[i]<r[0]&&i<j)i++;
if(i<j){
r[j]=r[i];
j--;
}
}while(i!=j);
r[i]=r[0];
quicksort(r,low,i-1);
quicksort(r,i+1,high);
}
}
int main(){
srand(time(NULL));
int r[100];
int n,k;
cout<<"n=";
cin>>n;
cout<<"k=";
cin>>k;
for(int i=0;i<n;i++){
r[i]=rand()%100;
}
quicksort(r,0,n-1);
for(i=0;i<n;i++){
cout<<r[i]<<endl;
}
cout<<r[n-k]<<endl;
}