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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;

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

        System.out.println(alice - bob);
    }
} import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;

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

        System.out.println(alice - bob);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;

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

        System.out.println(alice - bob);
    } main {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;

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

        System.out.println(alice - bob);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc final Integer[] a = new Integer[N]; a new Integer[N] N for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            a[i] = sc.nextInt();
        } {
            a[i] = sc.nextInt();
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc 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) alice += a[i];
            if (i % 2 != 0) bob += a[i];
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if (i % 2 == 0) alice += a[i];
            if (i % 2 != 0) bob += a[i];
        } {
            if (i % 2 == 0) alice += a[i];
            if (i % 2 != 0) bob += a[i];
        } if (i % 2 == 0) alice += a[i]; i % 2 == 0 i % 2 i 2 0 alice += a[i] alice a[i] a i if (i % 2 != 0) bob += a[i]; i % 2 != 0 i % 2 i 2 0 bob += a[i] bob a[i] a i 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 sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;

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

        System.out.println(alice - bob);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;

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

        System.out.println(alice - bob);
    }
} Main
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;

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

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