'use strict';

function Main(input) {
    // N K
    // P1 P2 ... PN
    let tmp = input.trim().split('\n');
    const NK = tmp[0].split(' ').map((v) => Number(v));
    const N = NK[0];
    const K = NK[1];
    const P = tmp[1]
        .split(' ')
        .map((v) => Number(v))
        .sort((a, b) => a - b);
    // console.log(N, K, P);

    let result = 0;
    for (let i = 0; i < K; i++) {
        result += P[i];
    }

    console.log(result);

    return;
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));