    #include <stdio.h>
    void main()
    {
 
        int i, j, a,v, n,sum=0, number[30];
        scanf("%d", &n);//total numbes
 
        scanf("%d",&v);
        //enter array element
        for (i = 0; i < n; ++i)
            scanf("%d", &number[i]);
 
        for (i = 0; i < n; ++i) 
        {
 
            for (j = i + 1; j < n; ++j)
            {
 
                if (number[i] > number[j]) 
                {
 
                    a =  number[i];
                    number[i] = number[j];
                    number[j] = a;
 
                }
 
            }
 
        }
 
       for (i = 0; i<=v; ++i)
            sum=number[i];
        printf("%d",sum);
 
    }