import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
     
class Main{
    public static void main(String arg[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        String A = sc.nextLine();
        Integer[] a = new Integer[N]; 

        sc.close();

        for(int i = 0; i < N; i++) {
            String[] s = A.split(" ");
            a[i] = Integer.parseInt(s[i]);
        }
        
        System.out.println(calc(a));    
    }
    
    public static int calc(Integer[] a) {
        int Alice = 0;
        int Bob = 0;
        
        Arrays.sort(a, Comparator.reverseOrder());

        for(int i = 0; i < a.length; i++){
            if(i % 2 == 0){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
        }
		return Alice - Bob;
    }
} import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util class Main{
    public static void main(String arg[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        String A = sc.nextLine();
        Integer[] a = new Integer[N]; 

        sc.close();

        for(int i = 0; i < N; i++) {
            String[] s = A.split(" ");
            a[i] = Integer.parseInt(s[i]);
        }
        
        System.out.println(calc(a));    
    }
    
    public static int calc(Integer[] a) {
        int Alice = 0;
        int Bob = 0;
        
        Arrays.sort(a, Comparator.reverseOrder());

        for(int i = 0; i < a.length; i++){
            if(i % 2 == 0){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
        }
		return Alice - Bob;
    }
} Main public static void main(String arg[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        String A = sc.nextLine();
        Integer[] a = new Integer[N]; 

        sc.close();

        for(int i = 0; i < N; i++) {
            String[] s = A.split(" ");
            a[i] = Integer.parseInt(s[i]);
        }
        
        System.out.println(calc(a));    
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        String A = sc.nextLine();
        Integer[] a = new Integer[N]; 

        sc.close();

        for(int i = 0; i < N; i++) {
            String[] s = A.split(" ");
            a[i] = Integer.parseInt(s[i]);
        }
        
        System.out.println(calc(a));    
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc String A = sc.nextLine(); A sc.nextLine() sc.nextLine sc Integer[] a = new Integer[N]; a new Integer[N] N sc.close() sc.close sc for(int i = 0; i < N; i++) {
            String[] s = A.split(" ");
            a[i] = Integer.parseInt(s[i]);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            String[] s = A.split(" ");
            a[i] = Integer.parseInt(s[i]);
        } {
            String[] s = A.split(" ");
            a[i] = Integer.parseInt(s[i]);
        } String[] s = A.split(" "); s A.split(" ") A.split A " " a[i] = Integer.parseInt(s[i]) a[i] a i Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i System.out.println(calc(a)) System.out.println System.out System System.out calc(a) calc a String arg[] arg public static int calc(Integer[] a) {
        int Alice = 0;
        int Bob = 0;
        
        Arrays.sort(a, Comparator.reverseOrder());

        for(int i = 0; i < a.length; i++){
            if(i % 2 == 0){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
        }
		return Alice - Bob;
    } calc {
        int Alice = 0;
        int Bob = 0;
        
        Arrays.sort(a, Comparator.reverseOrder());

        for(int i = 0; i < a.length; i++){
            if(i % 2 == 0){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
        }
		return Alice - Bob;
    } int Alice = 0; Alice 0 int Bob = 0; Bob 0 Arrays.sort(a, Comparator.reverseOrder()) Arrays.sort Arrays a Comparator.reverseOrder() Comparator.reverseOrder Comparator for(int i = 0; i < a.length; i++){
            if(i % 2 == 0){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
        } int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {
            if(i % 2 == 0){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
        } {
            if(i % 2 == 0){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
        } if(i % 2 == 0){
                Alice += a[i];
            }else{
                Bob += a[i];
            } i % 2 == 0 i % 2 i 2 0 {
                Alice += a[i];
            } Alice += a[i] Alice a[i] a i {
                Bob += a[i];
            } Bob += a[i] Bob a[i] a i return Alice - Bob; Alice - Bob Alice Bob Integer[] a a
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
     
class Main{
    public static void main(String arg[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        String A = sc.nextLine();
        Integer[] a = new Integer[N]; 

        sc.close();

        for(int i = 0; i < N; i++) {
            String[] s = A.split(" ");
            a[i] = Integer.parseInt(s[i]);
        }
        
        System.out.println(calc(a));    
    }
    
    public static int calc(Integer[] a) {
        int Alice = 0;
        int Bob = 0;
        
        Arrays.sort(a, Comparator.reverseOrder());

        for(int i = 0; i < a.length; i++){
            if(i % 2 == 0){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
        }
		return Alice - Bob;
    }
}