import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        Integer numMonster = sc.nextInt();
        Integer numHissatsu = sc.nextInt();
        sc.nextLine();
        
        int count = 0;
        long[] hpLine = new long[numMonster];
        while (sc.hasNext()) {
            long j = sc.nextInt();
            hpLine[count] = j;
            count++;
        }
        
        sc.close();
        
        Arrays.sort(hpLine);
        
        long cnt = 0;
        Integer startInt = numMonster - numHissatsu - 1;
        
        for(int i = startInt; i >= 0; i--) {
            cnt = cnt + hpLine[i];
        }
        
        System.out.println(cnt);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        Integer numMonster = sc.nextInt();
        Integer numHissatsu = sc.nextInt();
        sc.nextLine();
        
        int count = 0;
        long[] hpLine = new long[numMonster];
        while (sc.hasNext()) {
            long j = sc.nextInt();
            hpLine[count] = j;
            count++;
        }
        
        sc.close();
        
        Arrays.sort(hpLine);
        
        long cnt = 0;
        Integer startInt = numMonster - numHissatsu - 1;
        
        for(int i = startInt; i >= 0; i--) {
            cnt = cnt + hpLine[i];
        }
        
        System.out.println(cnt);
    }
} Main public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        Integer numMonster = sc.nextInt();
        Integer numHissatsu = sc.nextInt();
        sc.nextLine();
        
        int count = 0;
        long[] hpLine = new long[numMonster];
        while (sc.hasNext()) {
            long j = sc.nextInt();
            hpLine[count] = j;
            count++;
        }
        
        sc.close();
        
        Arrays.sort(hpLine);
        
        long cnt = 0;
        Integer startInt = numMonster - numHissatsu - 1;
        
        for(int i = startInt; i >= 0; i--) {
            cnt = cnt + hpLine[i];
        }
        
        System.out.println(cnt);
    } main {
        
        Scanner sc = new Scanner(System.in);
        
        Integer numMonster = sc.nextInt();
        Integer numHissatsu = sc.nextInt();
        sc.nextLine();
        
        int count = 0;
        long[] hpLine = new long[numMonster];
        while (sc.hasNext()) {
            long j = sc.nextInt();
            hpLine[count] = j;
            count++;
        }
        
        sc.close();
        
        Arrays.sort(hpLine);
        
        long cnt = 0;
        Integer startInt = numMonster - numHissatsu - 1;
        
        for(int i = startInt; i >= 0; i--) {
            cnt = cnt + hpLine[i];
        }
        
        System.out.println(cnt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Integer numMonster = sc.nextInt(); numMonster sc.nextInt() sc.nextInt sc Integer numHissatsu = sc.nextInt(); numHissatsu sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc int count = 0; count 0 long[] hpLine = new long[numMonster]; hpLine new long[numMonster] numMonster while (sc.hasNext()) {
            long j = sc.nextInt();
            hpLine[count] = j;
            count++;
        } sc.hasNext() sc.hasNext sc {
            long j = sc.nextInt();
            hpLine[count] = j;
            count++;
        } long j = sc.nextInt(); j sc.nextInt() sc.nextInt sc hpLine[count] = j hpLine[count] hpLine count j count++ count sc.close() sc.close sc Arrays.sort(hpLine) Arrays.sort Arrays hpLine long cnt = 0; cnt 0 Integer startInt = numMonster - numHissatsu - 1; startInt numMonster - numHissatsu - 1 numMonster - numHissatsu - 1 numMonster numHissatsu 1 for(int i = startInt; i >= 0; i--) {
            cnt = cnt + hpLine[i];
        } int i = startInt; int i = startInt; i startInt i >= 0 i 0 i-- i-- i {
            cnt = cnt + hpLine[i];
        } {
            cnt = cnt + hpLine[i];
        } cnt = cnt + hpLine[i] cnt cnt + hpLine[i] cnt hpLine[i] hpLine i System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        Integer numMonster = sc.nextInt();
        Integer numHissatsu = sc.nextInt();
        sc.nextLine();
        
        int count = 0;
        long[] hpLine = new long[numMonster];
        while (sc.hasNext()) {
            long j = sc.nextInt();
            hpLine[count] = j;
            count++;
        }
        
        sc.close();
        
        Arrays.sort(hpLine);
        
        long cnt = 0;
        Integer startInt = numMonster - numHissatsu - 1;
        
        for(int i = startInt; i >= 0; i--) {
            cnt = cnt + hpLine[i];
        }
        
        System.out.println(cnt);
    }
} public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        Integer numMonster = sc.nextInt();
        Integer numHissatsu = sc.nextInt();
        sc.nextLine();
        
        int count = 0;
        long[] hpLine = new long[numMonster];
        while (sc.hasNext()) {
            long j = sc.nextInt();
            hpLine[count] = j;
            count++;
        }
        
        sc.close();
        
        Arrays.sort(hpLine);
        
        long cnt = 0;
        Integer startInt = numMonster - numHissatsu - 1;
        
        for(int i = startInt; i >= 0; i--) {
            cnt = cnt + hpLine[i];
        }
        
        System.out.println(cnt);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        Integer numMonster = sc.nextInt();
        Integer numHissatsu = sc.nextInt();
        sc.nextLine();
        
        int count = 0;
        long[] hpLine = new long[numMonster];
        while (sc.hasNext()) {
            long j = sc.nextInt();
            hpLine[count] = j;
            count++;
        }
        
        sc.close();
        
        Arrays.sort(hpLine);
        
        long cnt = 0;
        Integer startInt = numMonster - numHissatsu - 1;
        
        for(int i = startInt; i >= 0; i--) {
            cnt = cnt + hpLine[i];
        }
        
        System.out.println(cnt);
    }
}
