import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        String[] line = scanner.nextLine().split(" ", n);
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }
        Arrays.sort(arr);

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++) {
            int num = arr[n - 1 - i];
            if (i % 2 == 0) {
                alice += num;
            } else {
                bob += num;
            }
        }
        System.out.println(alice - bob);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        String[] line = scanner.nextLine().split(" ", n);
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }
        Arrays.sort(arr);

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++) {
            int num = arr[n - 1 - i];
            if (i % 2 == 0) {
                alice += num;
            } else {
                bob += num;
            }
        }
        System.out.println(alice - bob);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        String[] line = scanner.nextLine().split(" ", n);
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }
        Arrays.sort(arr);

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++) {
            int num = arr[n - 1 - i];
            if (i % 2 == 0) {
                alice += num;
            } else {
                bob += num;
            }
        }
        System.out.println(alice - bob);
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        String[] line = scanner.nextLine().split(" ", n);
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }
        Arrays.sort(arr);

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++) {
            int num = arr[n - 1 - i];
            if (i % 2 == 0) {
                alice += num;
            } else {
                bob += num;
            }
        }
        System.out.println(alice - bob);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = Integer.parseInt(scanner.nextLine()); n Integer.parseInt(scanner.nextLine()) Integer.parseInt Integer scanner.nextLine() scanner.nextLine scanner String[] line = scanner.nextLine().split(" ", n); line scanner.nextLine().split(" ", n) scanner.nextLine().split scanner.nextLine() scanner.nextLine scanner " " n int[] arr = new int[n]; arr new int[n] n for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(line[i]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            arr[i] = Integer.parseInt(line[i]);
        } {
            arr[i] = Integer.parseInt(line[i]);
        } arr[i] = Integer.parseInt(line[i]) arr[i] arr i Integer.parseInt(line[i]) Integer.parseInt Integer line[i] line i Arrays.sort(arr) Arrays.sort Arrays arr int alice = 0; alice 0 int bob = 0; bob 0 for (int i = 0; i < n; i++) {
            int num = arr[n - 1 - i];
            if (i % 2 == 0) {
                alice += num;
            } else {
                bob += num;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int num = arr[n - 1 - i];
            if (i % 2 == 0) {
                alice += num;
            } else {
                bob += num;
            }
        } {
            int num = arr[n - 1 - i];
            if (i % 2 == 0) {
                alice += num;
            } else {
                bob += num;
            }
        } int num = arr[n - 1 - i]; num arr[n - 1 - i] arr n - 1 - i n - 1 - i n 1 i if (i % 2 == 0) {
                alice += num;
            } else {
                bob += num;
            } i % 2 == 0 i % 2 i 2 0 {
                alice += num;
            } alice += num alice num {
                bob += num;
            } bob += num bob num System.out.println(alice - bob) System.out.println System.out System System.out alice - bob alice bob String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        String[] line = scanner.nextLine().split(" ", n);
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }
        Arrays.sort(arr);

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++) {
            int num = arr[n - 1 - i];
            if (i % 2 == 0) {
                alice += num;
            } else {
                bob += num;
            }
        }
        System.out.println(alice - bob);
    }
}
