import java.util.Arrays;
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();
		}
		sc.close();
		Arrays.sort(arr);
		
		int alice = 0;
		int bob = 0;
		
		for(int i = 0; i < n; i++) {
			int now = arr[arr.length - 1 - i];
			if(i % 2 == 0) {
				alice += now;
			}else {
				bob += now;
			}
		}
		
		System.out.println(alice-bob);
	}
} import java.util.Arrays; Arrays 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();
		}
		sc.close();
		Arrays.sort(arr);
		
		int alice = 0;
		int bob = 0;
		
		for(int i = 0; i < n; i++) {
			int now = arr[arr.length - 1 - i];
			if(i % 2 == 0) {
				alice += now;
			}else {
				bob += now;
			}
		}
		
		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();
		}
		sc.close();
		Arrays.sort(arr);
		
		int alice = 0;
		int bob = 0;
		
		for(int i = 0; i < n; i++) {
			int now = arr[arr.length - 1 - i];
			if(i % 2 == 0) {
				alice += now;
			}else {
				bob += now;
			}
		}
		
		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();
		}
		sc.close();
		Arrays.sort(arr);
		
		int alice = 0;
		int bob = 0;
		
		for(int i = 0; i < n; i++) {
			int now = arr[arr.length - 1 - i];
			if(i % 2 == 0) {
				alice += now;
			}else {
				bob += now;
			}
		}
		
		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 sc.close() sc.close sc Arrays.sort(arr) Arrays.sort Arrays arr int alice = 0; alice 0 int bob = 0; bob 0 for(int i = 0; i < n; i++) {
			int now = arr[arr.length - 1 - i];
			if(i % 2 == 0) {
				alice += now;
			}else {
				bob += now;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int now = arr[arr.length - 1 - i];
			if(i % 2 == 0) {
				alice += now;
			}else {
				bob += now;
			}
		} {
			int now = arr[arr.length - 1 - i];
			if(i % 2 == 0) {
				alice += now;
			}else {
				bob += now;
			}
		} int now = arr[arr.length - 1 - i]; now arr[arr.length - 1 - i] arr arr.length - 1 - i arr.length - 1 - i arr.length arr arr.length 1 i if(i % 2 == 0) {
				alice += now;
			}else {
				bob += now;
			} i % 2 == 0 i % 2 i 2 0 {
				alice += now;
			} alice += now alice now {
				bob += now;
			} bob += now bob now 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();
		}
		sc.close();
		Arrays.sort(arr);
		
		int alice = 0;
		int bob = 0;
		
		for(int i = 0; i < n; i++) {
			int now = arr[arr.length - 1 - i];
			if(i % 2 == 0) {
				alice += now;
			}else {
				bob += now;
			}
		}
		
		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();
		}
		sc.close();
		Arrays.sort(arr);
		
		int alice = 0;
		int bob = 0;
		
		for(int i = 0; i < n; i++) {
			int now = arr[arr.length - 1 - i];
			if(i % 2 == 0) {
				alice += now;
			}else {
				bob += now;
			}
		}
		
		System.out.println(alice-bob);
	}
} Main
import java.util.Arrays;
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();
		}
		sc.close();
		Arrays.sort(arr);
		
		int alice = 0;
		int bob = 0;
		
		for(int i = 0; i < n; i++) {
			int now = arr[arr.length - 1 - i];
			if(i % 2 == 0) {
				alice += now;
			}else {
				bob += now;
			}
		}
		
		System.out.println(alice-bob);
	}
}
