import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        Integer [] list = new Integer[num];
        int Alice = 0;
        int Bob = 0;

        for(int i = 0; i < num; i++) {
            list[i] = scan.nextInt();
        }
        Arrays.sort(list, Collections.reverseOrder());
        for(int i = 0; i < num; i++){
            if(i % 2 == 0){
                Alice += list[i];
            }
            else{
                Bob += list[i];
            }
        }
        System.out.println(Alice - Bob);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        Integer [] list = new Integer[num];
        int Alice = 0;
        int Bob = 0;

        for(int i = 0; i < num; i++) {
            list[i] = scan.nextInt();
        }
        Arrays.sort(list, Collections.reverseOrder());
        for(int i = 0; i < num; i++){
            if(i % 2 == 0){
                Alice += list[i];
            }
            else{
                Bob += list[i];
            }
        }
        System.out.println(Alice - Bob);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        Integer [] list = new Integer[num];
        int Alice = 0;
        int Bob = 0;

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

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

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

        for(int i = 0; i < num; i++) {
            list[i] = scan.nextInt();
        }
        Arrays.sort(list, Collections.reverseOrder());
        for(int i = 0; i < num; i++){
            if(i % 2 == 0){
                Alice += list[i];
            }
            else{
                Bob += list[i];
            }
        }
        System.out.println(Alice - Bob);
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        Integer [] list = new Integer[num];
        int Alice = 0;
        int Bob = 0;

        for(int i = 0; i < num; i++) {
            list[i] = scan.nextInt();
        }
        Arrays.sort(list, Collections.reverseOrder());
        for(int i = 0; i < num; i++){
            if(i % 2 == 0){
                Alice += list[i];
            }
            else{
                Bob += list[i];
            }
        }
        System.out.println(Alice - Bob);
    }
}