import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        String inputDataRow1 = scanner.nextLine();
        String inputDataRow2 = scanner.nextLine();
        scanner.close();

        // 入力データの編集
        String[] editedInputDataRow1 = inputDataRow1.split(" ");
        int enemyCount = Integer.parseInt(editedInputDataRow1[0]);
        int skillCount = Integer.parseInt(editedInputDataRow1[1]);

        // モンスターの数で処理を分岐させる
        long totalDamageDemand = 0;
        if (enemyCount != 1) {
            String[] editedInputDataRow2 = inputDataRow2.split(" ");
            long[] enemyHPList = new long[enemyCount];
            for (int index = 0; index < enemyCount; index++) {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            }

            // モンスターのHPをソートする
            // 昇順
            Arrays.sort(enemyHPList);

            // 必要攻撃回数の判定
            enemyCount -= skillCount;
            for (int index = 0; index < enemyCount; index++) {
                totalDamageDemand += enemyHPList[index];
            }

        } else {
            long enemyHP = Long.parseLong(inputDataRow2);
            if (skillCount == 0) {
                totalDamageDemand = enemyHP;
            } else {
                totalDamageDemand = 0;
            }
        }

        // 結果の出力
        System.out.println(totalDamageDemand);

    }

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        String inputDataRow1 = scanner.nextLine();
        String inputDataRow2 = scanner.nextLine();
        scanner.close();

        // 入力データの編集
        String[] editedInputDataRow1 = inputDataRow1.split(" ");
        int enemyCount = Integer.parseInt(editedInputDataRow1[0]);
        int skillCount = Integer.parseInt(editedInputDataRow1[1]);

        // モンスターの数で処理を分岐させる
        long totalDamageDemand = 0;
        if (enemyCount != 1) {
            String[] editedInputDataRow2 = inputDataRow2.split(" ");
            long[] enemyHPList = new long[enemyCount];
            for (int index = 0; index < enemyCount; index++) {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            }

            // モンスターのHPをソートする
            // 昇順
            Arrays.sort(enemyHPList);

            // 必要攻撃回数の判定
            enemyCount -= skillCount;
            for (int index = 0; index < enemyCount; index++) {
                totalDamageDemand += enemyHPList[index];
            }

        } else {
            long enemyHP = Long.parseLong(inputDataRow2);
            if (skillCount == 0) {
                totalDamageDemand = enemyHP;
            } else {
                totalDamageDemand = 0;
            }
        }

        // 結果の出力
        System.out.println(totalDamageDemand);

    }

} Main public static void main(String[] args) throws Exception {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        String inputDataRow1 = scanner.nextLine();
        String inputDataRow2 = scanner.nextLine();
        scanner.close();

        // 入力データの編集
        String[] editedInputDataRow1 = inputDataRow1.split(" ");
        int enemyCount = Integer.parseInt(editedInputDataRow1[0]);
        int skillCount = Integer.parseInt(editedInputDataRow1[1]);

        // モンスターの数で処理を分岐させる
        long totalDamageDemand = 0;
        if (enemyCount != 1) {
            String[] editedInputDataRow2 = inputDataRow2.split(" ");
            long[] enemyHPList = new long[enemyCount];
            for (int index = 0; index < enemyCount; index++) {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            }

            // モンスターのHPをソートする
            // 昇順
            Arrays.sort(enemyHPList);

            // 必要攻撃回数の判定
            enemyCount -= skillCount;
            for (int index = 0; index < enemyCount; index++) {
                totalDamageDemand += enemyHPList[index];
            }

        } else {
            long enemyHP = Long.parseLong(inputDataRow2);
            if (skillCount == 0) {
                totalDamageDemand = enemyHP;
            } else {
                totalDamageDemand = 0;
            }
        }

        // 結果の出力
        System.out.println(totalDamageDemand);

    } main {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        String inputDataRow1 = scanner.nextLine();
        String inputDataRow2 = scanner.nextLine();
        scanner.close();

        // 入力データの編集
        String[] editedInputDataRow1 = inputDataRow1.split(" ");
        int enemyCount = Integer.parseInt(editedInputDataRow1[0]);
        int skillCount = Integer.parseInt(editedInputDataRow1[1]);

        // モンスターの数で処理を分岐させる
        long totalDamageDemand = 0;
        if (enemyCount != 1) {
            String[] editedInputDataRow2 = inputDataRow2.split(" ");
            long[] enemyHPList = new long[enemyCount];
            for (int index = 0; index < enemyCount; index++) {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            }

            // モンスターのHPをソートする
            // 昇順
            Arrays.sort(enemyHPList);

            // 必要攻撃回数の判定
            enemyCount -= skillCount;
            for (int index = 0; index < enemyCount; index++) {
                totalDamageDemand += enemyHPList[index];
            }

        } else {
            long enemyHP = Long.parseLong(inputDataRow2);
            if (skillCount == 0) {
                totalDamageDemand = enemyHP;
            } else {
                totalDamageDemand = 0;
            }
        }

        // 結果の出力
        System.out.println(totalDamageDemand);

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String inputDataRow1 = scanner.nextLine(); inputDataRow1 scanner.nextLine() scanner.nextLine scanner String inputDataRow2 = scanner.nextLine(); inputDataRow2 scanner.nextLine() scanner.nextLine scanner scanner.close() scanner.close scanner String[] editedInputDataRow1 = inputDataRow1.split(" "); editedInputDataRow1 inputDataRow1.split(" ") inputDataRow1.split inputDataRow1 " " int enemyCount = Integer.parseInt(editedInputDataRow1[0]); enemyCount Integer.parseInt(editedInputDataRow1[0]) Integer.parseInt Integer editedInputDataRow1[0] editedInputDataRow1 0 int skillCount = Integer.parseInt(editedInputDataRow1[1]); skillCount Integer.parseInt(editedInputDataRow1[1]) Integer.parseInt Integer editedInputDataRow1[1] editedInputDataRow1 1 long totalDamageDemand = 0; totalDamageDemand 0 if (enemyCount != 1) {
            String[] editedInputDataRow2 = inputDataRow2.split(" ");
            long[] enemyHPList = new long[enemyCount];
            for (int index = 0; index < enemyCount; index++) {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            }

            // モンスターのHPをソートする
            // 昇順
            Arrays.sort(enemyHPList);

            // 必要攻撃回数の判定
            enemyCount -= skillCount;
            for (int index = 0; index < enemyCount; index++) {
                totalDamageDemand += enemyHPList[index];
            }

        } else {
            long enemyHP = Long.parseLong(inputDataRow2);
            if (skillCount == 0) {
                totalDamageDemand = enemyHP;
            } else {
                totalDamageDemand = 0;
            }
        } enemyCount != 1 enemyCount 1 {
            String[] editedInputDataRow2 = inputDataRow2.split(" ");
            long[] enemyHPList = new long[enemyCount];
            for (int index = 0; index < enemyCount; index++) {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            }

            // モンスターのHPをソートする
            // 昇順
            Arrays.sort(enemyHPList);

            // 必要攻撃回数の判定
            enemyCount -= skillCount;
            for (int index = 0; index < enemyCount; index++) {
                totalDamageDemand += enemyHPList[index];
            }

        } String[] editedInputDataRow2 = inputDataRow2.split(" "); editedInputDataRow2 inputDataRow2.split(" ") inputDataRow2.split inputDataRow2 " " long[] enemyHPList = new long[enemyCount]; enemyHPList new long[enemyCount] enemyCount for (int index = 0; index < enemyCount; index++) {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            } int index = 0; int index = 0; index 0 index < enemyCount index enemyCount index++ index++ index {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            } {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            } enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]) enemyHPList[index] enemyHPList index Long.parseLong(editedInputDataRow2[index]) Long.parseLong Long editedInputDataRow2[index] editedInputDataRow2 index Arrays.sort(enemyHPList) Arrays.sort Arrays enemyHPList enemyCount -= skillCount enemyCount skillCount for (int index = 0; index < enemyCount; index++) {
                totalDamageDemand += enemyHPList[index];
            } int index = 0; int index = 0; index 0 index < enemyCount index enemyCount index++ index++ index {
                totalDamageDemand += enemyHPList[index];
            } {
                totalDamageDemand += enemyHPList[index];
            } totalDamageDemand += enemyHPList[index] totalDamageDemand enemyHPList[index] enemyHPList index {
            long enemyHP = Long.parseLong(inputDataRow2);
            if (skillCount == 0) {
                totalDamageDemand = enemyHP;
            } else {
                totalDamageDemand = 0;
            }
        } long enemyHP = Long.parseLong(inputDataRow2); enemyHP Long.parseLong(inputDataRow2) Long.parseLong Long inputDataRow2 if (skillCount == 0) {
                totalDamageDemand = enemyHP;
            } else {
                totalDamageDemand = 0;
            } skillCount == 0 skillCount 0 {
                totalDamageDemand = enemyHP;
            } totalDamageDemand = enemyHP totalDamageDemand enemyHP {
                totalDamageDemand = 0;
            } totalDamageDemand = 0 totalDamageDemand 0 System.out.println(totalDamageDemand) System.out.println System.out System System.out totalDamageDemand String[] args args public class Main {
    public static void main(String[] args) throws Exception {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        String inputDataRow1 = scanner.nextLine();
        String inputDataRow2 = scanner.nextLine();
        scanner.close();

        // 入力データの編集
        String[] editedInputDataRow1 = inputDataRow1.split(" ");
        int enemyCount = Integer.parseInt(editedInputDataRow1[0]);
        int skillCount = Integer.parseInt(editedInputDataRow1[1]);

        // モンスターの数で処理を分岐させる
        long totalDamageDemand = 0;
        if (enemyCount != 1) {
            String[] editedInputDataRow2 = inputDataRow2.split(" ");
            long[] enemyHPList = new long[enemyCount];
            for (int index = 0; index < enemyCount; index++) {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            }

            // モンスターのHPをソートする
            // 昇順
            Arrays.sort(enemyHPList);

            // 必要攻撃回数の判定
            enemyCount -= skillCount;
            for (int index = 0; index < enemyCount; index++) {
                totalDamageDemand += enemyHPList[index];
            }

        } else {
            long enemyHP = Long.parseLong(inputDataRow2);
            if (skillCount == 0) {
                totalDamageDemand = enemyHP;
            } else {
                totalDamageDemand = 0;
            }
        }

        // 結果の出力
        System.out.println(totalDamageDemand);

    }

} public class Main {
    public static void main(String[] args) throws Exception {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        String inputDataRow1 = scanner.nextLine();
        String inputDataRow2 = scanner.nextLine();
        scanner.close();

        // 入力データの編集
        String[] editedInputDataRow1 = inputDataRow1.split(" ");
        int enemyCount = Integer.parseInt(editedInputDataRow1[0]);
        int skillCount = Integer.parseInt(editedInputDataRow1[1]);

        // モンスターの数で処理を分岐させる
        long totalDamageDemand = 0;
        if (enemyCount != 1) {
            String[] editedInputDataRow2 = inputDataRow2.split(" ");
            long[] enemyHPList = new long[enemyCount];
            for (int index = 0; index < enemyCount; index++) {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            }

            // モンスターのHPをソートする
            // 昇順
            Arrays.sort(enemyHPList);

            // 必要攻撃回数の判定
            enemyCount -= skillCount;
            for (int index = 0; index < enemyCount; index++) {
                totalDamageDemand += enemyHPList[index];
            }

        } else {
            long enemyHP = Long.parseLong(inputDataRow2);
            if (skillCount == 0) {
                totalDamageDemand = enemyHP;
            } else {
                totalDamageDemand = 0;
            }
        }

        // 結果の出力
        System.out.println(totalDamageDemand);

    }

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        String inputDataRow1 = scanner.nextLine();
        String inputDataRow2 = scanner.nextLine();
        scanner.close();

        // 入力データの編集
        String[] editedInputDataRow1 = inputDataRow1.split(" ");
        int enemyCount = Integer.parseInt(editedInputDataRow1[0]);
        int skillCount = Integer.parseInt(editedInputDataRow1[1]);

        // モンスターの数で処理を分岐させる
        long totalDamageDemand = 0;
        if (enemyCount != 1) {
            String[] editedInputDataRow2 = inputDataRow2.split(" ");
            long[] enemyHPList = new long[enemyCount];
            for (int index = 0; index < enemyCount; index++) {
                enemyHPList[index] = Long.parseLong(editedInputDataRow2[index]);
            }

            // モンスターのHPをソートする
            // 昇順
            Arrays.sort(enemyHPList);

            // 必要攻撃回数の判定
            enemyCount -= skillCount;
            for (int index = 0; index < enemyCount; index++) {
                totalDamageDemand += enemyHPList[index];
            }

        } else {
            long enemyHP = Long.parseLong(inputDataRow2);
            if (skillCount == 0) {
                totalDamageDemand = enemyHP;
            } else {
                totalDamageDemand = 0;
            }
        }

        // 結果の出力
        System.out.println(totalDamageDemand);

    }

}