import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        int result = 0;
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer card[] = new Integer[n];
        
        for (int i=0; i < n; i++){
            card[i] = sc.nextInt();
        }
            
        Arrays.sort(card,Collections.reverseOrder());
        
        int alice = 0;
        int bob = 0;
        
        for (int i=0; i < n; i++){
            if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            }
        }
        
        System.out.println(alice - bob);
        sc.close();
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        
        int result = 0;
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer card[] = new Integer[n];
        
        for (int i=0; i < n; i++){
            card[i] = sc.nextInt();
        }
            
        Arrays.sort(card,Collections.reverseOrder());
        
        int alice = 0;
        int bob = 0;
        
        for (int i=0; i < n; i++){
            if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            }
        }
        
        System.out.println(alice - bob);
        sc.close();
    }
} Main public static void main(String[] args) throws Exception {
        
        int result = 0;
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer card[] = new Integer[n];
        
        for (int i=0; i < n; i++){
            card[i] = sc.nextInt();
        }
            
        Arrays.sort(card,Collections.reverseOrder());
        
        int alice = 0;
        int bob = 0;
        
        for (int i=0; i < n; i++){
            if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            }
        }
        
        System.out.println(alice - bob);
        sc.close();
    } main {
        
        int result = 0;
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer card[] = new Integer[n];
        
        for (int i=0; i < n; i++){
            card[i] = sc.nextInt();
        }
            
        Arrays.sort(card,Collections.reverseOrder());
        
        int alice = 0;
        int bob = 0;
        
        for (int i=0; i < n; i++){
            if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            }
        }
        
        System.out.println(alice - bob);
        sc.close();
    } int result = 0; result 0 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Integer card[] = new Integer[n]; card new Integer[n] n for (int i=0; i < n; i++){
            card[i] = sc.nextInt();
        } int i=0; int i=0; i 0 i < n i n i++ i++ i {
            card[i] = sc.nextInt();
        } {
            card[i] = sc.nextInt();
        } card[i] = sc.nextInt() card[i] card i sc.nextInt() sc.nextInt sc Arrays.sort(card,Collections.reverseOrder()) Arrays.sort Arrays card Collections.reverseOrder() Collections.reverseOrder Collections int alice = 0; alice 0 int bob = 0; bob 0 for (int i=0; i < n; i++){
            if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            }
        } int i=0; int i=0; i 0 i < n i n i++ i++ i {
            if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            }
        } {
            if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            }
        } if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            } i % 2 == 0 i % 2 i 2 0 {
                alice += card[i];
            } alice += card[i] alice card[i] card i {
                bob += card[i];
            } bob += card[i] bob card[i] card i 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) throws Exception {
        
        int result = 0;
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer card[] = new Integer[n];
        
        for (int i=0; i < n; i++){
            card[i] = sc.nextInt();
        }
            
        Arrays.sort(card,Collections.reverseOrder());
        
        int alice = 0;
        int bob = 0;
        
        for (int i=0; i < n; i++){
            if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            }
        }
        
        System.out.println(alice - bob);
        sc.close();
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        
        int result = 0;
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer card[] = new Integer[n];
        
        for (int i=0; i < n; i++){
            card[i] = sc.nextInt();
        }
            
        Arrays.sort(card,Collections.reverseOrder());
        
        int alice = 0;
        int bob = 0;
        
        for (int i=0; i < n; i++){
            if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            }
        }
        
        System.out.println(alice - bob);
        sc.close();
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        int result = 0;
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer card[] = new Integer[n];
        
        for (int i=0; i < n; i++){
            card[i] = sc.nextInt();
        }
            
        Arrays.sort(card,Collections.reverseOrder());
        
        int alice = 0;
        int bob = 0;
        
        for (int i=0; i < n; i++){
            if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            }
        }
        
        System.out.println(alice - bob);
        sc.close();
    }
}
