import 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];
        int sumA = 0;
        int sumB = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for (int i = n - 1; i >= 0; i -= 2) {
            sumA += a[i];
        }
        for (int i = n - 2; i >= 0; i -= 2) {
            sumB += a[i];
        }
        System.out.println(sumA - sumB);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int sumA = 0;
        int sumB = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for (int i = n - 1; i >= 0; i -= 2) {
            sumA += a[i];
        }
        for (int i = n - 2; i >= 0; i -= 2) {
            sumB += a[i];
        }
        System.out.println(sumA - sumB);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int sumA = 0;
        int sumB = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for (int i = n - 1; i >= 0; i -= 2) {
            sumA += a[i];
        }
        for (int i = n - 2; i >= 0; i -= 2) {
            sumB += a[i];
        }
        System.out.println(sumA - sumB);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int sumA = 0;
        int sumB = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for (int i = n - 1; i >= 0; i -= 2) {
            sumA += a[i];
        }
        for (int i = n - 2; i >= 0; i -= 2) {
            sumB += a[i];
        }
        System.out.println(sumA - sumB);
    } 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 int sumA = 0; sumA 0 int sumB = 0; sumB 0 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 for (int i = n - 1; i >= 0; i -= 2) {
            sumA += a[i];
        } int i = n - 1; int i = n - 1; i n - 1 n 1 i >= 0 i 0 i -= 2 i -= 2 i 2 {
            sumA += a[i];
        } {
            sumA += a[i];
        } sumA += a[i] sumA a[i] a i for (int i = n - 2; i >= 0; i -= 2) {
            sumB += a[i];
        } int i = n - 2; int i = n - 2; i n - 2 n 2 i >= 0 i 0 i -= 2 i -= 2 i 2 {
            sumB += a[i];
        } {
            sumB += a[i];
        } sumB += a[i] sumB a[i] a i System.out.println(sumA - sumB) System.out.println System.out System System.out sumA - sumB sumA sumB 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];
        int sumA = 0;
        int sumB = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for (int i = n - 1; i >= 0; i -= 2) {
            sumA += a[i];
        }
        for (int i = n - 2; i >= 0; i -= 2) {
            sumB += a[i];
        }
        System.out.println(sumA - sumB);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int sumA = 0;
        int sumB = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for (int i = n - 1; i >= 0; i -= 2) {
            sumA += a[i];
        }
        for (int i = n - 2; i >= 0; i -= 2) {
            sumB += a[i];
        }
        System.out.println(sumA - sumB);
    }
} Main
import 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];
        int sumA = 0;
        int sumB = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for (int i = n - 1; i >= 0; i -= 2) {
            sumA += a[i];
        }
        for (int i = n - 2; i >= 0; i -= 2) {
            sumB += a[i];
        }
        System.out.println(sumA - sumB);
    }
}