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

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice_total = 0;
        int bob_total = 0;
        for (int k = 0; k<N; k++) {
            if (k%2 == 0) {
                alice_total+=a[k];
            } else {
                bob_total += a[k];
            }
        }
        System.out.println(alice_total - bob_total);
    }
} 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(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice_total = 0;
        int bob_total = 0;
        for (int k = 0; k<N; k++) {
            if (k%2 == 0) {
                alice_total+=a[k];
            } else {
                bob_total += a[k];
            }
        }
        System.out.println(alice_total - bob_total);
    }
} Main public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice_total = 0;
        int bob_total = 0;
        for (int k = 0; k<N; k++) {
            if (k%2 == 0) {
                alice_total+=a[k];
            } else {
                bob_total += a[k];
            }
        }
        System.out.println(alice_total - bob_total);
    } main {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice_total = 0;
        int bob_total = 0;
        for (int k = 0; k<N; k++) {
            if (k%2 == 0) {
                alice_total+=a[k];
            } else {
                bob_total += a[k];
            }
        }
        System.out.println(alice_total - bob_total);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt 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_total = 0; alice_total 0 int bob_total = 0; bob_total 0 for (int k = 0; k<N; k++) {
            if (k%2 == 0) {
                alice_total+=a[k];
            } else {
                bob_total += a[k];
            }
        } int k = 0; int k = 0; k 0 k<N k N k++ k++ k {
            if (k%2 == 0) {
                alice_total+=a[k];
            } else {
                bob_total += a[k];
            }
        } {
            if (k%2 == 0) {
                alice_total+=a[k];
            } else {
                bob_total += a[k];
            }
        } if (k%2 == 0) {
                alice_total+=a[k];
            } else {
                bob_total += a[k];
            } k%2 == 0 k%2 k 2 0 {
                alice_total+=a[k];
            } alice_total+=a[k] alice_total a[k] a k {
                bob_total += a[k];
            } bob_total += a[k] bob_total a[k] a k System.out.println(alice_total - bob_total) System.out.println System.out System System.out alice_total - bob_total alice_total bob_total final String[] args args
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice_total = 0;
        int bob_total = 0;
        for (int k = 0; k<N; k++) {
            if (k%2 == 0) {
                alice_total+=a[k];
            } else {
                bob_total += a[k];
            }
        }
        System.out.println(alice_total - bob_total);
    }
}
