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

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer num[] = new Integer[n];
        for (int i = 0; i < n; i++) {
            num[i] = scan.nextInt();
        }
        Arrays.sort(num, Collections.reverseOrder());
        int Alice = 0;
        int Bob = 0;
        for(int i=0; i< num.length; i++) {
            if(i % 2 ==0 ) {
                Alice = Alice + num[i];
            } else {
                Bob = Bob + num[i];
            }
        }
        System.out.print(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 scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer num[] = new Integer[n];
        for (int i = 0; i < n; i++) {
            num[i] = scan.nextInt();
        }
        Arrays.sort(num, Collections.reverseOrder());
        int Alice = 0;
        int Bob = 0;
        for(int i=0; i< num.length; i++) {
            if(i % 2 ==0 ) {
                Alice = Alice + num[i];
            } else {
                Bob = Bob + num[i];
            }
        }
        System.out.print(Alice - Bob);
    }
} Main public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer num[] = new Integer[n];
        for (int i = 0; i < n; i++) {
            num[i] = scan.nextInt();
        }
        Arrays.sort(num, Collections.reverseOrder());
        int Alice = 0;
        int Bob = 0;
        for(int i=0; i< num.length; i++) {
            if(i % 2 ==0 ) {
                Alice = Alice + num[i];
            } else {
                Bob = Bob + num[i];
            }
        }
        System.out.print(Alice - Bob);
    } main {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer num[] = new Integer[n];
        for (int i = 0; i < n; i++) {
            num[i] = scan.nextInt();
        }
        Arrays.sort(num, Collections.reverseOrder());
        int Alice = 0;
        int Bob = 0;
        for(int i=0; i< num.length; i++) {
            if(i % 2 ==0 ) {
                Alice = Alice + num[i];
            } else {
                Bob = Bob + num[i];
            }
        }
        System.out.print(Alice - Bob);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = Integer.parseInt(scan.next()); n Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan Integer num[] = new Integer[n]; num new Integer[n] n for (int i = 0; i < n; i++) {
            num[i] = scan.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            num[i] = scan.nextInt();
        } {
            num[i] = scan.nextInt();
        } num[i] = scan.nextInt() num[i] num i scan.nextInt() scan.nextInt scan Arrays.sort(num, Collections.reverseOrder()) Arrays.sort Arrays num Collections.reverseOrder() Collections.reverseOrder Collections int Alice = 0; Alice 0 int Bob = 0; Bob 0 for(int i=0; i< num.length; i++) {
            if(i % 2 ==0 ) {
                Alice = Alice + num[i];
            } else {
                Bob = Bob + num[i];
            }
        } int i=0; int i=0; i 0 i< num.length i num.length num num.length i++ i++ i {
            if(i % 2 ==0 ) {
                Alice = Alice + num[i];
            } else {
                Bob = Bob + num[i];
            }
        } {
            if(i % 2 ==0 ) {
                Alice = Alice + num[i];
            } else {
                Bob = Bob + num[i];
            }
        } if(i % 2 ==0 ) {
                Alice = Alice + num[i];
            } else {
                Bob = Bob + num[i];
            } i % 2 ==0 i % 2 i 2 0 {
                Alice = Alice + num[i];
            } Alice = Alice + num[i] Alice Alice + num[i] Alice num[i] num i {
                Bob = Bob + num[i];
            } Bob = Bob + num[i] Bob Bob + num[i] Bob num[i] num i System.out.print(Alice - Bob) System.out.print System.out System System.out Alice - Bob Alice Bob String[] args args public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer num[] = new Integer[n];
        for (int i = 0; i < n; i++) {
            num[i] = scan.nextInt();
        }
        Arrays.sort(num, Collections.reverseOrder());
        int Alice = 0;
        int Bob = 0;
        for(int i=0; i< num.length; i++) {
            if(i % 2 ==0 ) {
                Alice = Alice + num[i];
            } else {
                Bob = Bob + num[i];
            }
        }
        System.out.print(Alice - Bob);
    }
} public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer num[] = new Integer[n];
        for (int i = 0; i < n; i++) {
            num[i] = scan.nextInt();
        }
        Arrays.sort(num, Collections.reverseOrder());
        int Alice = 0;
        int Bob = 0;
        for(int i=0; i< num.length; i++) {
            if(i % 2 ==0 ) {
                Alice = Alice + num[i];
            } else {
                Bob = Bob + num[i];
            }
        }
        System.out.print(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 scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer num[] = new Integer[n];
        for (int i = 0; i < n; i++) {
            num[i] = scan.nextInt();
        }
        Arrays.sort(num, Collections.reverseOrder());
        int Alice = 0;
        int Bob = 0;
        for(int i=0; i< num.length; i++) {
            if(i % 2 ==0 ) {
                Alice = Alice + num[i];
            } else {
                Bob = Bob + num[i];
            }
        }
        System.out.print(Alice - Bob);
    }
}

