"use strict";

const main = arg => {
    // 標準入力の不要な空白と改行を削除し、配列に格納する
    let input = arg.trim().split("\n").map(low => low.split(" ").map(str => Math.floor(str, 10)))

    for (let i=0; i<input[0][1]; i++) {
        let isMaxNum = num => num == Math.max(...input[1]);
        let maxNumIndex = input[1].findIndex(isMaxNum);
        input[1][maxNumIndex] = 0;
    }

    const returnSum = (a, n) => a + n;

    console.log(input[1].reduce(returnSum));

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  