const main = (input: string) => {
    const inputs: string[] = input.split('\n');
    const [N, K] = inputs[0].split(' ').map(x => parseInt(x));
    const fruits = inputs[1].split(' ').map(x => parseInt(x));

    fruits.sort((a, b) => (
        a - b
    ));
    console.log(fruits[0] + fruits[1] + fruits[2]);
};
// 標準入力
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
