import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();
        List<Integer> ll = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            ll.add(sc.nextInt());
        }
        Collections.sort(ll);
        Collections.reverse(ll);
        long ans1 = 0;
        for (int i = 0; i < Math.min(k, n); i++) {
            ans1 += ll.get(i);
        }
        long ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans2 += ll.get(i);
        }
        System.out.println(ans2 - ans1);
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();
        List<Integer> ll = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            ll.add(sc.nextInt());
        }
        Collections.sort(ll);
        Collections.reverse(ll);
        long ans1 = 0;
        for (int i = 0; i < Math.min(k, n); i++) {
            ans1 += ll.get(i);
        }
        long ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans2 += ll.get(i);
        }
        System.out.println(ans2 - ans1);
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();
        List<Integer> ll = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            ll.add(sc.nextInt());
        }
        Collections.sort(ll);
        Collections.reverse(ll);
        long ans1 = 0;
        for (int i = 0; i < Math.min(k, n); i++) {
            ans1 += ll.get(i);
        }
        long ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans2 += ll.get(i);
        }
        System.out.println(ans2 - ans1);
    } main {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();
        List<Integer> ll = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            ll.add(sc.nextInt());
        }
        Collections.sort(ll);
        Collections.reverse(ll);
        long ans1 = 0;
        for (int i = 0; i < Math.min(k, n); i++) {
            ans1 += ll.get(i);
        }
        long ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans2 += ll.get(i);
        }
        System.out.println(ans2 - ans1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long k = sc.nextInt(); k sc.nextInt() sc.nextInt sc List<Integer> ll = new ArrayList<>(); ll new ArrayList<>() for (int i = 0; i < n; i++) {
            ll.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            ll.add(sc.nextInt());
        } {
            ll.add(sc.nextInt());
        } ll.add(sc.nextInt()) ll.add ll sc.nextInt() sc.nextInt sc Collections.sort(ll) Collections.sort Collections ll Collections.reverse(ll) Collections.reverse Collections ll long ans1 = 0; ans1 0 for (int i = 0; i < Math.min(k, n); i++) {
            ans1 += ll.get(i);
        } int i = 0; int i = 0; i 0 i < Math.min(k, n) i Math.min(k, n) Math.min Math k n i++ i++ i {
            ans1 += ll.get(i);
        } {
            ans1 += ll.get(i);
        } ans1 += ll.get(i) ans1 ll.get(i) ll.get ll i long ans2 = 0; ans2 0 for (int i = 0; i < n; i++) {
            ans2 += ll.get(i);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            ans2 += ll.get(i);
        } {
            ans2 += ll.get(i);
        } ans2 += ll.get(i) ans2 ll.get(i) ll.get ll i System.out.println(ans2 - ans1) System.out.println System.out System System.out ans2 - ans1 ans2 ans1 String[] args args public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    } log2 {
        return (int) (Math.log(x) / Math.log(2));
    } return (int) (Math.log(x) / Math.log(2)); (int) (Math.log(x) / Math.log(2)) Math.log(x) Math.log Math x Math.log(2) Math.log Math 2 long x x public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();
        List<Integer> ll = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            ll.add(sc.nextInt());
        }
        Collections.sort(ll);
        Collections.reverse(ll);
        long ans1 = 0;
        for (int i = 0; i < Math.min(k, n); i++) {
            ans1 += ll.get(i);
        }
        long ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans2 += ll.get(i);
        }
        System.out.println(ans2 - ans1);
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();
        List<Integer> ll = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            ll.add(sc.nextInt());
        }
        Collections.sort(ll);
        Collections.reverse(ll);
        long ans1 = 0;
        for (int i = 0; i < Math.min(k, n); i++) {
            ans1 += ll.get(i);
        }
        long ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans2 += ll.get(i);
        }
        System.out.println(ans2 - ans1);
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();
        List<Integer> ll = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            ll.add(sc.nextInt());
        }
        Collections.sort(ll);
        Collections.reverse(ll);
        long ans1 = 0;
        for (int i = 0; i < Math.min(k, n); i++) {
            ans1 += ll.get(i);
        }
        long ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans2 += ll.get(i);
        }
        System.out.println(ans2 - ans1);
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
}
