#include<stdio.h>

int main(void){
    int max,fluet;
    int alt;
    int sum = 0;
    int price[256];

    if(scanf("%d%d",&max,&fluet) != 2){
        return -1;
    }

    for(int i = 0;i < max;i++){
        if(scanf("%d",&price[i]) != 1){
            retyrn -1;
        }
    }

    for(int i = 0;i < max - 1;i++){
        for(int j = i + 1;j < max;j++){
            if(price[i] > price[j]){
                alt = price[i];
                price[i] = price[j];
                price[j] = alt;
            }
        }
    }

    for(int k = 0;k < fluet;k++){
        sum += price[k];
    }

     printf("%d\n",sum);

     return 0;
}
