import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int k = 0;
        int Alice = 0;
        int Bob = 0;
        while(k < n){
            if(k%2==0){
                Alice += a[n - 1 - k];
            }else{
                Bob += a[n - 1 - k];
            }
            k++;
        }
        System.out.println(Alice - Bob);
        sc.close();
    }
} import java.util.*; util.* java import java.lang.*; lang.* 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];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int k = 0;
        int Alice = 0;
        int Bob = 0;
        while(k < n){
            if(k%2==0){
                Alice += a[n - 1 - k];
            }else{
                Bob += a[n - 1 - k];
            }
            k++;
        }
        System.out.println(Alice - Bob);
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int k = 0;
        int Alice = 0;
        int Bob = 0;
        while(k < n){
            if(k%2==0){
                Alice += a[n - 1 - k];
            }else{
                Bob += a[n - 1 - k];
            }
            k++;
        }
        System.out.println(Alice - Bob);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int k = 0;
        int Alice = 0;
        int Bob = 0;
        while(k < n){
            if(k%2==0){
                Alice += a[n - 1 - k];
            }else{
                Bob += a[n - 1 - k];
            }
            k++;
        }
        System.out.println(Alice - Bob);
        sc.close();
    } 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 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 int k = 0; k 0 int Alice = 0; Alice 0 int Bob = 0; Bob 0 while(k < n){
            if(k%2==0){
                Alice += a[n - 1 - k];
            }else{
                Bob += a[n - 1 - k];
            }
            k++;
        } k < n k n {
            if(k%2==0){
                Alice += a[n - 1 - k];
            }else{
                Bob += a[n - 1 - k];
            }
            k++;
        } if(k%2==0){
                Alice += a[n - 1 - k];
            }else{
                Bob += a[n - 1 - k];
            } k%2==0 k%2 k 2 0 {
                Alice += a[n - 1 - k];
            } Alice += a[n - 1 - k] Alice a[n - 1 - k] a n - 1 - k n - 1 - k n 1 k {
                Bob += a[n - 1 - k];
            } Bob += a[n - 1 - k] Bob a[n - 1 - k] a n - 1 - k n - 1 - k n 1 k k++ k System.out.println(Alice - Bob) System.out.println System.out System System.out Alice - Bob Alice Bob sc.close() sc.close sc 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];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int k = 0;
        int Alice = 0;
        int Bob = 0;
        while(k < n){
            if(k%2==0){
                Alice += a[n - 1 - k];
            }else{
                Bob += a[n - 1 - k];
            }
            k++;
        }
        System.out.println(Alice - Bob);
        sc.close();
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int k = 0;
        int Alice = 0;
        int Bob = 0;
        while(k < n){
            if(k%2==0){
                Alice += a[n - 1 - k];
            }else{
                Bob += a[n - 1 - k];
            }
            k++;
        }
        System.out.println(Alice - Bob);
        sc.close();
    }
} Main
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int k = 0;
        int Alice = 0;
        int Bob = 0;
        while(k < n){
            if(k%2==0){
                Alice += a[n - 1 - k];
            }else{
                Bob += a[n - 1 - k];
            }
            k++;
        }
        System.out.println(Alice - Bob);
        sc.close();
    }
}