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

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        Integer[] A = new Integer[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        Arrays.sort(A, Collections.reverseOrder());

        int alice = 0, bob = 0;

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

        System.out.println(alice - bob);
    }
} import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        Integer[] A = new Integer[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        Arrays.sort(A, Collections.reverseOrder());

        int alice = 0, bob = 0;

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

        System.out.println(alice - bob);
    }
} Main public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        Integer[] A = new Integer[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        Arrays.sort(A, Collections.reverseOrder());

        int alice = 0, bob = 0;

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

        System.out.println(alice - bob);
    } main {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        Integer[] A = new Integer[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        Arrays.sort(A, Collections.reverseOrder());

        int alice = 0, bob = 0;

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

        System.out.println(alice - bob);
    } Scanner cin = new Scanner(System.in); cin new Scanner(System.in) int N = cin.nextInt(); N cin.nextInt() cin.nextInt cin Integer[] A = new Integer[N]; A new Integer[N] N for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            A[i] = cin.nextInt();
        } {
            A[i] = cin.nextInt();
        } A[i] = cin.nextInt() A[i] A i cin.nextInt() cin.nextInt cin Arrays.sort(A, Collections.reverseOrder()) Arrays.sort Arrays A Collections.reverseOrder() Collections.reverseOrder Collections int alice = 0 alice 0 bob = 0; bob 0 for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                alice += A[i];
            } else {
                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];
            } else {
                bob += A[i];
            }
        } {
            if (i % 2 == 0) {
                alice += A[i];
            } else {
                bob += A[i];
            }
        } if (i % 2 == 0) {
                alice += A[i];
            } else {
                bob += A[i];
            } i % 2 == 0 i % 2 i 2 0 {
                alice += A[i];
            } alice += A[i] alice A[i] A i {
                bob += A[i];
            } 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 cin = new Scanner(System.in);
        int N = cin.nextInt();
        Integer[] A = new Integer[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        Arrays.sort(A, Collections.reverseOrder());

        int alice = 0, bob = 0;

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

        System.out.println(alice - bob);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        Integer[] A = new Integer[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        Arrays.sort(A, Collections.reverseOrder());

        int alice = 0, bob = 0;

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

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

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        Integer[] A = new Integer[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        Arrays.sort(A, Collections.reverseOrder());

        int alice = 0, bob = 0;

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

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