<?php
    list($N, $K) = explode(' ', trim(fgets(STDIN)));
    $fruits = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $total = 0;
    
    sort($fruits, SORT_NUMERIC);
    var_dump($fruits);
    
    for($i = 0; $i < $K; $i++){
        $total += $fruits[$i];
    }
    echo $total;
?>