import java.util.*;

public class Solution {
    public int findKth(int[] a, int n, int K) {
        // write code here
        quickSort(a,0,n-1,K);
        int i=n-1;
        for(;i>=n-K+1;i--){
            ;
        }
        return a[i];

    }
    public void quickSort(int[] a,int left,int right,int K){
        if(left>right){
            return;
        }
        boolean flag=false;
        int piovt=partion(a,left,right);
        if(piovt==a.length-K){
            flag=true;
            return;
        }
        quickSort(a,left,piovt-1,K);
        if(flag){
            return;
        }
        quickSort(a,piovt+1,right,K);
        if(flag){
            return;
        }
    }
    public int partion(int[] a,int left,int right){
        int tmp=a[left];
        while(left<right){
            while(right>left&&a[right]>=tmp){
                right--;
            }
            a[left]=a[right];
            while(left<right&&a[left]<=tmp){
                left++;
            }
            a[right]=a[left];
            
        }
        a[left]=tmp;
        return left;
    }
   
}