import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        int a = 0;
        int b = 0;
        
        String[] input = br.readLine().split(" ");
        Integer[] numbers = new Integer[n];
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.valueOf(input[i]);
        }
        
        Arrays.sort(numbers, Collections.reverseOrder());
        
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                a += numbers[i];
            }else{
                b += numbers[i];
            }
        }
        
        out.println(a - b);
        out.close();
        
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        int a = 0;
        int b = 0;
        
        String[] input = br.readLine().split(" ");
        Integer[] numbers = new Integer[n];
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.valueOf(input[i]);
        }
        
        Arrays.sort(numbers, Collections.reverseOrder());
        
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                a += numbers[i];
            }else{
                b += numbers[i];
            }
        }
        
        out.println(a - b);
        out.close();
        
    }
} Main public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        int a = 0;
        int b = 0;
        
        String[] input = br.readLine().split(" ");
        Integer[] numbers = new Integer[n];
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.valueOf(input[i]);
        }
        
        Arrays.sort(numbers, Collections.reverseOrder());
        
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                a += numbers[i];
            }else{
                b += numbers[i];
            }
        }
        
        out.println(a - b);
        out.close();
        
    } main {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        int a = 0;
        int b = 0;
        
        String[] input = br.readLine().split(" ");
        Integer[] numbers = new Integer[n];
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.valueOf(input[i]);
        }
        
        Arrays.sort(numbers, Collections.reverseOrder());
        
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                a += numbers[i];
            }else{
                b += numbers[i];
            }
        }
        
        out.println(a - b);
        out.close();
        
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); out new PrintWriter(new OutputStreamWriter(System.out)) int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int a = 0; a 0 int b = 0; b 0 String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Integer[] numbers = new Integer[n]; numbers new Integer[n] n for(int i = 0; i < n; i++){
            numbers[i] = Integer.valueOf(input[i]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            numbers[i] = Integer.valueOf(input[i]);
        } {
            numbers[i] = Integer.valueOf(input[i]);
        } numbers[i] = Integer.valueOf(input[i]) numbers[i] numbers i Integer.valueOf(input[i]) Integer.valueOf Integer input[i] input i Arrays.sort(numbers, Collections.reverseOrder()) Arrays.sort Arrays numbers Collections.reverseOrder() Collections.reverseOrder Collections for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                a += numbers[i];
            }else{
                b += numbers[i];
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if(i % 2 == 0){
                a += numbers[i];
            }else{
                b += numbers[i];
            }
        } {
            if(i % 2 == 0){
                a += numbers[i];
            }else{
                b += numbers[i];
            }
        } if(i % 2 == 0){
                a += numbers[i];
            }else{
                b += numbers[i];
            } i % 2 == 0 i % 2 i 2 0 {
                a += numbers[i];
            } a += numbers[i] a numbers[i] numbers i {
                b += numbers[i];
            } b += numbers[i] b numbers[i] numbers i out.println(a - b) out.println out a - b a b out.close() out.close out String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        int a = 0;
        int b = 0;
        
        String[] input = br.readLine().split(" ");
        Integer[] numbers = new Integer[n];
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.valueOf(input[i]);
        }
        
        Arrays.sort(numbers, Collections.reverseOrder());
        
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                a += numbers[i];
            }else{
                b += numbers[i];
            }
        }
        
        out.println(a - b);
        out.close();
        
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        int a = 0;
        int b = 0;
        
        String[] input = br.readLine().split(" ");
        Integer[] numbers = new Integer[n];
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.valueOf(input[i]);
        }
        
        Arrays.sort(numbers, Collections.reverseOrder());
        
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                a += numbers[i];
            }else{
                b += numbers[i];
            }
        }
        
        out.println(a - b);
        out.close();
        
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        int a = 0;
        int b = 0;
        
        String[] input = br.readLine().split(" ");
        Integer[] numbers = new Integer[n];
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.valueOf(input[i]);
        }
        
        Arrays.sort(numbers, Collections.reverseOrder());
        
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                a += numbers[i];
            }else{
                b += numbers[i];
            }
        }
        
        out.println(a - b);
        out.close();
        
    }
}