import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input;
        input = new Scanner(System.in);
        int N = input.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++){
            a[i] = input.nextInt();
        }
        Arrays.sort(a,Comparator.reverseOrder());
        int A = 0;
        int B = 0;
        for (int i = 0; i < N; i++){
            if (i%2 == 0){
                A += a[i];
            }
            else{
                B += a[i];
            }
        }
        System.out.println(A-B);
    }
} import java.util.*; util.* java import java.util.stream.*; stream.* java.util class Main {
    public static void main(String[] args) {
        Scanner input;
        input = new Scanner(System.in);
        int N = input.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++){
            a[i] = input.nextInt();
        }
        Arrays.sort(a,Comparator.reverseOrder());
        int A = 0;
        int B = 0;
        for (int i = 0; i < N; i++){
            if (i%2 == 0){
                A += a[i];
            }
            else{
                B += a[i];
            }
        }
        System.out.println(A-B);
    }
} Main public static void main(String[] args) {
        Scanner input;
        input = new Scanner(System.in);
        int N = input.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++){
            a[i] = input.nextInt();
        }
        Arrays.sort(a,Comparator.reverseOrder());
        int A = 0;
        int B = 0;
        for (int i = 0; i < N; i++){
            if (i%2 == 0){
                A += a[i];
            }
            else{
                B += a[i];
            }
        }
        System.out.println(A-B);
    } main {
        Scanner input;
        input = new Scanner(System.in);
        int N = input.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++){
            a[i] = input.nextInt();
        }
        Arrays.sort(a,Comparator.reverseOrder());
        int A = 0;
        int B = 0;
        for (int i = 0; i < N; i++){
            if (i%2 == 0){
                A += a[i];
            }
            else{
                B += a[i];
            }
        }
        System.out.println(A-B);
    } Scanner input; input input = new Scanner(System.in) input new Scanner(System.in) int N = input.nextInt(); N input.nextInt() input.nextInt input Integer[] a = new Integer[N]; a new Integer[N] N for (int i = 0; i < N; i++){
            a[i] = input.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            a[i] = input.nextInt();
        } {
            a[i] = input.nextInt();
        } a[i] = input.nextInt() a[i] a i input.nextInt() input.nextInt input Arrays.sort(a,Comparator.reverseOrder()) Arrays.sort Arrays a Comparator.reverseOrder() Comparator.reverseOrder Comparator int A = 0; A 0 int B = 0; B 0 for (int i = 0; i < N; i++){
            if (i%2 == 0){
                A += a[i];
            }
            else{
                B += a[i];
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if (i%2 == 0){
                A += a[i];
            }
            else{
                B += a[i];
            }
        } {
            if (i%2 == 0){
                A += a[i];
            }
            else{
                B += a[i];
            }
        } if (i%2 == 0){
                A += a[i];
            }
            else{
                B += a[i];
            } i%2 == 0 i%2 i 2 0 {
                A += a[i];
            } A += a[i] A a[i] a i {
                B += a[i];
            } B += a[i] B a[i] a i System.out.println(A-B) System.out.println System.out System System.out A-B A B String[] args args
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input;
        input = new Scanner(System.in);
        int N = input.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++){
            a[i] = input.nextInt();
        }
        Arrays.sort(a,Comparator.reverseOrder());
        int A = 0;
        int B = 0;
        for (int i = 0; i < N; i++){
            if (i%2 == 0){
                A += a[i];
            }
            else{
                B += a[i];
            }
        }
        System.out.println(A-B);
    }
}