#include<stdio.h>
int main(){
    int a, b, c[999], i, j, w, g;
    scanf("%d %d",&a, &b);
    for ( i = 0; i < a; i++)
    {
        scanf("%d",&c[i]);
    }
    
    for ( i = 0; i < a; i++)
    {
        for (j = (i + 1); j < a; j++)
        {
            if (c[i] > c[j])
            {
                w = c[i];
                c[i] = c[j];
                c[j] = w;
            }
            
        }
        
    }

    
    for ( i = 0; i < b; i++)
    {
        g = 0:
        g = g + c[i];
    }
    printf("%d\n",g);
    return 0;
}