import java.util.*;
import java.io.*;

public class Main{
  static BufferedReader in;
  static StringTokenizer str=null;
  
  static int nextInt() throws Exception{
    
    if (str==null||!str.hasMoreTokens()){
      str = new StringTokenizer(in.readLine());
    }
    return Integer.parseInt(str.nextToken());
  }

  public static void main(String args[]) throws Exception{
    in = new BufferedReader(new FileReader(new File("A.in")));
    PrintWriter out = new PrintWriter(new File("A.out"));
    int n = nextInt();
    int k = nextInt();
    int a[] = new int[n];
    for (int i=0;i<n;i++){
      a[i] = nextInt();
    }
    Arrays.sort(a);
    int c = n-k;
    long sum=0;
    for (int i=n-1;i>=n-c;i--){
      sum+=a[i]; 
    }
    out.println(sum);
    out.close();
  }
}