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

public class Main {

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

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);

        int Alice = 0;
        int Bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            }
        }

        System.out.printf("%d\n", Alice - Bob);
        sc.close();
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

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

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);

        int Alice = 0;
        int Bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            }
        }

        System.out.printf("%d\n", Alice - Bob);
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);

        int Alice = 0;
        int Bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            }
        }

        System.out.printf("%d\n", Alice - Bob);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);

        int Alice = 0;
        int Bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            }
        }

        System.out.printf("%d\n", Alice - Bob);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] A = new int[N]; A new int[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) Arrays.sort Arrays A int Alice = 0; Alice 0 int Bob = 0; Bob 0 for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            }
        } {
            if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            }
        } if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            } i % 2 == 0 i % 2 i 2 0 {
                Alice += A[N-1-i];
            } Alice += A[N-1-i] Alice A[N-1-i] A N-1-i N-1-i N 1 i {
                Bob += A[N-1-i];
            } Bob += A[N-1-i] Bob A[N-1-i] A N-1-i N-1-i N 1 i System.out.printf("%d\n", Alice - Bob) System.out.printf System.out System System.out "%d\n" Alice - Bob Alice Bob sc.close() sc.close sc String[] args args public class Main {

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

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);

        int Alice = 0;
        int Bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            }
        }

        System.out.printf("%d\n", Alice - Bob);
        sc.close();
    }
} public class Main {

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

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);

        int Alice = 0;
        int Bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            }
        }

        System.out.printf("%d\n", Alice - Bob);
        sc.close();
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);

        int Alice = 0;
        int Bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            }
        }

        System.out.printf("%d\n", Alice - Bob);
        sc.close();
    }
}