import java.util.*;
import java.util.ArrayList;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i=0;i<n;i++){
            a.add(scanner.nextInt());
        }
        int alice=0;
        int bob=0;
        Collections.sort(a);
        for (int i=0;i<n;i++){
            if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            }
            a.remove(n-i-1);
        }
        System.out.println(alice-bob);

    }

} import java.util.*; util.* java import java.util.ArrayList; ArrayList java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i=0;i<n;i++){
            a.add(scanner.nextInt());
        }
        int alice=0;
        int bob=0;
        Collections.sort(a);
        for (int i=0;i<n;i++){
            if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            }
            a.remove(n-i-1);
        }
        System.out.println(alice-bob);

    }

} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i=0;i<n;i++){
            a.add(scanner.nextInt());
        }
        int alice=0;
        int bob=0;
        Collections.sort(a);
        for (int i=0;i<n;i++){
            if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            }
            a.remove(n-i-1);
        }
        System.out.println(alice-bob);

    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i=0;i<n;i++){
            a.add(scanner.nextInt());
        }
        int alice=0;
        int bob=0;
        Collections.sort(a);
        for (int i=0;i<n;i++){
            if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            }
            a.remove(n-i-1);
        }
        System.out.println(alice-bob);

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner ArrayList<Integer> a = new ArrayList<>(); a new ArrayList<>() for (int i=0;i<n;i++){
            a.add(scanner.nextInt());
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            a.add(scanner.nextInt());
        } {
            a.add(scanner.nextInt());
        } a.add(scanner.nextInt()) a.add a scanner.nextInt() scanner.nextInt scanner int alice=0; alice 0 int bob=0; bob 0 Collections.sort(a) Collections.sort Collections a for (int i=0;i<n;i++){
            if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            }
            a.remove(n-i-1);
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            }
            a.remove(n-i-1);
        } {
            if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            }
            a.remove(n-i-1);
        } if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            } i%2==0 i%2 i 2 0 {
                alice += a.get(n-i-1);
            } alice += a.get(n-i-1) alice a.get(n-i-1) a.get a n-i-1 n-i-1 n i 1 {
                bob += a.get(n-i-1);
            } bob += a.get(n-i-1) bob a.get(n-i-1) a.get a n-i-1 n-i-1 n i 1 a.remove(n-i-1) a.remove a n-i-1 n-i-1 n i 1 System.out.println(alice-bob) System.out.println System.out System System.out alice-bob alice bob String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i=0;i<n;i++){
            a.add(scanner.nextInt());
        }
        int alice=0;
        int bob=0;
        Collections.sort(a);
        for (int i=0;i<n;i++){
            if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            }
            a.remove(n-i-1);
        }
        System.out.println(alice-bob);

    }

} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i=0;i<n;i++){
            a.add(scanner.nextInt());
        }
        int alice=0;
        int bob=0;
        Collections.sort(a);
        for (int i=0;i<n;i++){
            if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            }
            a.remove(n-i-1);
        }
        System.out.println(alice-bob);

    }

} Main
import java.util.*;
import java.util.ArrayList;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i=0;i<n;i++){
            a.add(scanner.nextInt());
        }
        int alice=0;
        int bob=0;
        Collections.sort(a);
        for (int i=0;i<n;i++){
            if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            }
            a.remove(n-i-1);
        }
        System.out.println(alice-bob);

    }

}