import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int alice = 0;
        int bob = 0;
        for(int j = 0; j < N; j++) {
            if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            }
        }
        System.out.println(alice - bob);
    }
} import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int alice = 0;
        int bob = 0;
        for(int j = 0; j < N; j++) {
            if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            }
        }
        System.out.println(alice - bob);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int alice = 0;
        int bob = 0;
        for(int j = 0; j < N; j++) {
            if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            }
        }
        System.out.println(alice - bob);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int alice = 0;
        int bob = 0;
        for(int j = 0; j < N; j++) {
            if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            }
        }
        System.out.println(alice - bob);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] arr = new int[N]; arr new int[N] N for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            arr[i] = sc.nextInt();
        } {
            arr[i] = sc.nextInt();
        } arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc Arrays.sort(arr) Arrays.sort Arrays arr int alice = 0; alice 0 int bob = 0; bob 0 for(int j = 0; j < N; j++) {
            if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            }
        } int j = 0; int j = 0; j 0 j < N j N j++ j++ j {
            if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            }
        } {
            if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            }
        } if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            } j % 2 == 0 j % 2 j 2 0 {
                alice += arr[N - 1 - j];
            } alice += arr[N - 1 - j] alice arr[N - 1 - j] arr N - 1 - j N - 1 - j N 1 j {
                bob += arr[N - 1 -j];
            } bob += arr[N - 1 -j] bob arr[N - 1 -j] arr N - 1 -j N - 1 -j N 1 j 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 sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int alice = 0;
        int bob = 0;
        for(int j = 0; j < N; j++) {
            if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            }
        }
        System.out.println(alice - bob);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int alice = 0;
        int bob = 0;
        for(int j = 0; j < N; j++) {
            if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            }
        }
        System.out.println(alice - bob);
    }
} Main
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int alice = 0;
        int bob = 0;
        for(int j = 0; j < N; j++) {
            if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            }
        }
        System.out.println(alice - bob);
    }
}
