import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int k = Integer.parseInt(input[1]);

        int remain = n - k;
        if (remain < 0) {
            System.out.println(0);
            return;
        }

        List<Long> hpList = new ArrayList<>();
        for (String hp : sc.nextLine().split(" ")) {
            hpList.add(Long.parseLong(hp));
        }

        Collections.sort(hpList);
        Collections.reverse(hpList);
        List<Long> remainedEnemies = hpList.subList(hpList.size() - remain, hpList.size());

        long sum = 0;
        for (Long remainedEnemy : remainedEnemies) {
            sum += remainedEnemy.intValue();
        }

        System.out.println(sum);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int k = Integer.parseInt(input[1]);

        int remain = n - k;
        if (remain < 0) {
            System.out.println(0);
            return;
        }

        List<Long> hpList = new ArrayList<>();
        for (String hp : sc.nextLine().split(" ")) {
            hpList.add(Long.parseLong(hp));
        }

        Collections.sort(hpList);
        Collections.reverse(hpList);
        List<Long> remainedEnemies = hpList.subList(hpList.size() - remain, hpList.size());

        long sum = 0;
        for (Long remainedEnemy : remainedEnemies) {
            sum += remainedEnemy.intValue();
        }

        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int k = Integer.parseInt(input[1]);

        int remain = n - k;
        if (remain < 0) {
            System.out.println(0);
            return;
        }

        List<Long> hpList = new ArrayList<>();
        for (String hp : sc.nextLine().split(" ")) {
            hpList.add(Long.parseLong(hp));
        }

        Collections.sort(hpList);
        Collections.reverse(hpList);
        List<Long> remainedEnemies = hpList.subList(hpList.size() - remain, hpList.size());

        long sum = 0;
        for (Long remainedEnemy : remainedEnemies) {
            sum += remainedEnemy.intValue();
        }

        System.out.println(sum);
    } main {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int k = Integer.parseInt(input[1]);

        int remain = n - k;
        if (remain < 0) {
            System.out.println(0);
            return;
        }

        List<Long> hpList = new ArrayList<>();
        for (String hp : sc.nextLine().split(" ")) {
            hpList.add(Long.parseLong(hp));
        }

        Collections.sort(hpList);
        Collections.reverse(hpList);
        List<Long> remainedEnemies = hpList.subList(hpList.size() - remain, hpList.size());

        long sum = 0;
        for (Long remainedEnemy : remainedEnemies) {
            sum += remainedEnemy.intValue();
        }

        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] input = sc.nextLine().split(" "); input sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int n = Integer.parseInt(input[0]); n Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int k = Integer.parseInt(input[1]); k Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 int remain = n - k; remain n - k n k if (remain < 0) {
            System.out.println(0);
            return;
        } remain < 0 remain 0 {
            System.out.println(0);
            return;
        } System.out.println(0) System.out.println System.out System System.out 0 return; List<Long> hpList = new ArrayList<>(); hpList new ArrayList<>() for (String hp : sc.nextLine().split(" ")) {
            hpList.add(Long.parseLong(hp));
        } String hp sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " {
            hpList.add(Long.parseLong(hp));
        } {
            hpList.add(Long.parseLong(hp));
        } hpList.add(Long.parseLong(hp)) hpList.add hpList Long.parseLong(hp) Long.parseLong Long hp Collections.sort(hpList) Collections.sort Collections hpList Collections.reverse(hpList) Collections.reverse Collections hpList List<Long> remainedEnemies = hpList.subList(hpList.size() - remain, hpList.size()); remainedEnemies hpList.subList(hpList.size() - remain, hpList.size()) hpList.subList hpList hpList.size() - remain hpList.size() hpList.size hpList remain hpList.size() hpList.size hpList long sum = 0; sum 0 for (Long remainedEnemy : remainedEnemies) {
            sum += remainedEnemy.intValue();
        } Long remainedEnemy remainedEnemies {
            sum += remainedEnemy.intValue();
        } {
            sum += remainedEnemy.intValue();
        } sum += remainedEnemy.intValue() sum remainedEnemy.intValue() remainedEnemy.intValue remainedEnemy System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {

    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int k = Integer.parseInt(input[1]);

        int remain = n - k;
        if (remain < 0) {
            System.out.println(0);
            return;
        }

        List<Long> hpList = new ArrayList<>();
        for (String hp : sc.nextLine().split(" ")) {
            hpList.add(Long.parseLong(hp));
        }

        Collections.sort(hpList);
        Collections.reverse(hpList);
        List<Long> remainedEnemies = hpList.subList(hpList.size() - remain, hpList.size());

        long sum = 0;
        for (Long remainedEnemy : remainedEnemies) {
            sum += remainedEnemy.intValue();
        }

        System.out.println(sum);
    }
} public class Main {

    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int k = Integer.parseInt(input[1]);

        int remain = n - k;
        if (remain < 0) {
            System.out.println(0);
            return;
        }

        List<Long> hpList = new ArrayList<>();
        for (String hp : sc.nextLine().split(" ")) {
            hpList.add(Long.parseLong(hp));
        }

        Collections.sort(hpList);
        Collections.reverse(hpList);
        List<Long> remainedEnemies = hpList.subList(hpList.size() - remain, hpList.size());

        long sum = 0;
        for (Long remainedEnemy : remainedEnemies) {
            sum += remainedEnemy.intValue();
        }

        System.out.println(sum);
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int k = Integer.parseInt(input[1]);

        int remain = n - k;
        if (remain < 0) {
            System.out.println(0);
            return;
        }

        List<Long> hpList = new ArrayList<>();
        for (String hp : sc.nextLine().split(" ")) {
            hpList.add(Long.parseLong(hp));
        }

        Collections.sort(hpList);
        Collections.reverse(hpList);
        List<Long> remainedEnemies = hpList.subList(hpList.size() - remain, hpList.size());

        long sum = 0;
        for (Long remainedEnemy : remainedEnemies) {
            sum += remainedEnemy.intValue();
        }

        System.out.println(sum);
    }
}