"use strict";

const main = arg => {
    const input = arg.trim().split('\n');
    let first = input[0].trim().split(' ');
    let second = input[1].trim().split(' ');
    
    function compareFunc(a, b) {
          return a - b;
        }
         
    let numArr = second.map(Number).sort(compareFunc);
    
    let result = 0;
    
    for (let i = 0; i<first[1]; i++) {
        result = result + numArr[i];
    }
    console.log(result)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  