import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] s = scanner.nextLine().split(" ");
        int an[] = new int[n];
        for (int i = 0; i < n; i++) {
            an[i] = Integer.parseInt(s[i]);
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            }
        }
        int diff = 0;
        for (int i = 0; i < n - 1; i += 2) {
            diff += an[i] - an[i + 1];
        }
        if (n % 2 == 1) {
            diff += an[n - 1];
        }

        System.out.println(diff);
        scanner.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] s = scanner.nextLine().split(" ");
        int an[] = new int[n];
        for (int i = 0; i < n; i++) {
            an[i] = Integer.parseInt(s[i]);
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            }
        }
        int diff = 0;
        for (int i = 0; i < n - 1; i += 2) {
            diff += an[i] - an[i + 1];
        }
        if (n % 2 == 1) {
            diff += an[n - 1];
        }

        System.out.println(diff);
        scanner.close();
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] s = scanner.nextLine().split(" ");
        int an[] = new int[n];
        for (int i = 0; i < n; i++) {
            an[i] = Integer.parseInt(s[i]);
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            }
        }
        int diff = 0;
        for (int i = 0; i < n - 1; i += 2) {
            diff += an[i] - an[i + 1];
        }
        if (n % 2 == 1) {
            diff += an[n - 1];
        }

        System.out.println(diff);
        scanner.close();
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] s = scanner.nextLine().split(" ");
        int an[] = new int[n];
        for (int i = 0; i < n; i++) {
            an[i] = Integer.parseInt(s[i]);
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            }
        }
        int diff = 0;
        for (int i = 0; i < n - 1; i += 2) {
            diff += an[i] - an[i + 1];
        }
        if (n % 2 == 1) {
            diff += an[n - 1];
        }

        System.out.println(diff);
        scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = Integer.parseInt(scanner.nextLine()); n Integer.parseInt(scanner.nextLine()) Integer.parseInt Integer scanner.nextLine() scanner.nextLine scanner String[] s = scanner.nextLine().split(" "); s scanner.nextLine().split(" ") scanner.nextLine().split scanner.nextLine() scanner.nextLine scanner " " int an[] = new int[n]; an new int[n] n for (int i = 0; i < n; i++) {
            an[i] = Integer.parseInt(s[i]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            an[i] = Integer.parseInt(s[i]);
        } {
            an[i] = Integer.parseInt(s[i]);
        } an[i] = Integer.parseInt(s[i]) an[i] an i Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            }
        } int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
            for (int j = i + 1; j < n; j++) {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            }
        } {
            for (int j = i + 1; j < n; j++) {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            }
        } for (int j = i + 1; j < n; j++) {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            } int j = i + 1; int j = i + 1; j i + 1 i 1 j < n j n j++ j++ j {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            } {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            } if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                } an[i] < an[j] an[i] an i an[j] an j {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                } int tmp = an[i]; tmp an[i] an i an[i] = an[j] an[i] an i an[j] an j an[j] = tmp an[j] an j tmp int diff = 0; diff 0 for (int i = 0; i < n - 1; i += 2) {
            diff += an[i] - an[i + 1];
        } int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i += 2 i += 2 i 2 {
            diff += an[i] - an[i + 1];
        } {
            diff += an[i] - an[i + 1];
        } diff += an[i] - an[i + 1] diff an[i] - an[i + 1] an[i] an i an[i + 1] an i + 1 i 1 if (n % 2 == 1) {
            diff += an[n - 1];
        } n % 2 == 1 n % 2 n 2 1 {
            diff += an[n - 1];
        } diff += an[n - 1] diff an[n - 1] an n - 1 n 1 System.out.println(diff) System.out.println System.out System System.out diff scanner.close() scanner.close scanner String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] s = scanner.nextLine().split(" ");
        int an[] = new int[n];
        for (int i = 0; i < n; i++) {
            an[i] = Integer.parseInt(s[i]);
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            }
        }
        int diff = 0;
        for (int i = 0; i < n - 1; i += 2) {
            diff += an[i] - an[i + 1];
        }
        if (n % 2 == 1) {
            diff += an[n - 1];
        }

        System.out.println(diff);
        scanner.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] s = scanner.nextLine().split(" ");
        int an[] = new int[n];
        for (int i = 0; i < n; i++) {
            an[i] = Integer.parseInt(s[i]);
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            }
        }
        int diff = 0;
        for (int i = 0; i < n - 1; i += 2) {
            diff += an[i] - an[i + 1];
        }
        if (n % 2 == 1) {
            diff += an[n - 1];
        }

        System.out.println(diff);
        scanner.close();
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] s = scanner.nextLine().split(" ");
        int an[] = new int[n];
        for (int i = 0; i < n; i++) {
            an[i] = Integer.parseInt(s[i]);
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (an[i] < an[j]) {
                    int tmp = an[i];
                    an[i] = an[j];
                    an[j] = tmp;
                }
            }
        }
        int diff = 0;
        for (int i = 0; i < n - 1; i += 2) {
            diff += an[i] - an[i + 1];
        }
        if (n % 2 == 1) {
            diff += an[n - 1];
        }

        System.out.println(diff);
        scanner.close();
    }
}
