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

class Main {
    
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        List<Long> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(scanner.nextLong());
        }
        scanner.close();
        Collections.sort(list);
        long sum = 0;
        for(int i=list.size()-1; i>=0; i--){
            if(i>list.size()-1-k){
                continue;
            }
            sum += list.get(i);
        }
        System.out.println(sum);
    }
    
} import java.util.Scanner; Scanner java.util import java.util.List; List java.util import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util class Main {
    
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        List<Long> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(scanner.nextLong());
        }
        scanner.close();
        Collections.sort(list);
        long sum = 0;
        for(int i=list.size()-1; i>=0; i--){
            if(i>list.size()-1-k){
                continue;
            }
            sum += list.get(i);
        }
        System.out.println(sum);
    }
    
} Main public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        List<Long> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(scanner.nextLong());
        }
        scanner.close();
        Collections.sort(list);
        long sum = 0;
        for(int i=list.size()-1; i>=0; i--){
            if(i>list.size()-1-k){
                continue;
            }
            sum += list.get(i);
        }
        System.out.println(sum);
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        List<Long> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(scanner.nextLong());
        }
        scanner.close();
        Collections.sort(list);
        long sum = 0;
        for(int i=list.size()-1; i>=0; i--){
            if(i>list.size()-1-k){
                continue;
            }
            sum += list.get(i);
        }
        System.out.println(sum);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner List<Long> list = new ArrayList<>(); list new ArrayList<>() for(int i=0; i<n; i++){
            list.add(scanner.nextLong());
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            list.add(scanner.nextLong());
        } {
            list.add(scanner.nextLong());
        } list.add(scanner.nextLong()) list.add list scanner.nextLong() scanner.nextLong scanner scanner.close() scanner.close scanner Collections.sort(list) Collections.sort Collections list long sum = 0; sum 0 for(int i=list.size()-1; i>=0; i--){
            if(i>list.size()-1-k){
                continue;
            }
            sum += list.get(i);
        } int i=list.size()-1; int i=list.size()-1; i list.size()-1 list.size() list.size list 1 i>=0 i 0 i-- i-- i {
            if(i>list.size()-1-k){
                continue;
            }
            sum += list.get(i);
        } {
            if(i>list.size()-1-k){
                continue;
            }
            sum += list.get(i);
        } if(i>list.size()-1-k){
                continue;
            } i>list.size()-1-k i list.size()-1-k list.size()-1-k list.size() list.size list 1 k {
                continue;
            } continue; sum += list.get(i) sum list.get(i) list.get list i System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

class Main {
    
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        List<Long> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(scanner.nextLong());
        }
        scanner.close();
        Collections.sort(list);
        long sum = 0;
        for(int i=list.size()-1; i>=0; i--){
            if(i>list.size()-1-k){
                continue;
            }
            sum += list.get(i);
        }
        System.out.println(sum);
    }
    
}