import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer[] a = new Integer[n];

        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 != 0) {
                bob += a[i];
            } else {
                alice += a[i];
            }
        }

        System.out.print(alice - bob);
    }
} import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer[] a = new Integer[n];

        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 != 0) {
                bob += a[i];
            } else {
                alice += a[i];
            }
        }

        System.out.print(alice - bob);
    }
} Main public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer[] a = new Integer[n];

        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 != 0) {
                bob += a[i];
            } else {
                alice += a[i];
            }
        }

        System.out.print(alice - bob);
    } main {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer[] a = new Integer[n];

        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 != 0) {
                bob += a[i];
            } else {
                alice += a[i];
            }
        }

        System.out.print(alice - bob);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = Integer.parseInt(scan.next()); n Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan Integer[] a = new Integer[n]; a new Integer[n] n for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a[i] = scan.nextInt();
        } {
            a[i] = scan.nextInt();
        } a[i] = scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan Arrays.sort(a, Comparator.reverseOrder()) Arrays.sort Arrays a Comparator.reverseOrder() Comparator.reverseOrder Comparator int alice = 0; alice 0 int bob = 0; bob 0 for (int i = 0; i < n; i++) {
            if (i % 2 != 0) {
                bob += a[i];
            } else {
                alice += a[i];
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if (i % 2 != 0) {
                bob += a[i];
            } else {
                alice += a[i];
            }
        } {
            if (i % 2 != 0) {
                bob += a[i];
            } else {
                alice += a[i];
            }
        } if (i % 2 != 0) {
                bob += a[i];
            } else {
                alice += a[i];
            } i % 2 != 0 i % 2 i 2 0 {
                bob += a[i];
            } bob += a[i] bob a[i] a i {
                alice += a[i];
            } alice += a[i] alice a[i] a i System.out.print(alice - bob) System.out.print System.out System System.out alice - bob alice bob String[] args args
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer[] a = new Integer[n];

        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 != 0) {
                bob += a[i];
            } else {
                alice += a[i];
            }
        }

        System.out.print(alice - bob);
    }
}