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();
		Integer[] a = new Integer[n];

		int i = 0;
		while(sc.hasNext()) {
			a[i] = sc.nextInt();
			i++;
		}

		Arrays.sort(a, Collections.reverseOrder());

		int Alice = 0;
		int Bob = 0;
		int diff = 0;
		for(int j=0; j<a.length; j++) {
			if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			}
		}
		diff = Alice - Bob;
		System.out.println(diff);
	}
} 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();
		Integer[] a = new Integer[n];

		int i = 0;
		while(sc.hasNext()) {
			a[i] = sc.nextInt();
			i++;
		}

		Arrays.sort(a, Collections.reverseOrder());

		int Alice = 0;
		int Bob = 0;
		int diff = 0;
		for(int j=0; j<a.length; j++) {
			if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			}
		}
		diff = Alice - Bob;
		System.out.println(diff);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] a = new Integer[n];

		int i = 0;
		while(sc.hasNext()) {
			a[i] = sc.nextInt();
			i++;
		}

		Arrays.sort(a, Collections.reverseOrder());

		int Alice = 0;
		int Bob = 0;
		int diff = 0;
		for(int j=0; j<a.length; j++) {
			if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			}
		}
		diff = Alice - Bob;
		System.out.println(diff);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] a = new Integer[n];

		int i = 0;
		while(sc.hasNext()) {
			a[i] = sc.nextInt();
			i++;
		}

		Arrays.sort(a, Collections.reverseOrder());

		int Alice = 0;
		int Bob = 0;
		int diff = 0;
		for(int j=0; j<a.length; j++) {
			if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			}
		}
		diff = Alice - Bob;
		System.out.println(diff);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Integer[] a = new Integer[n]; a new Integer[n] n int i = 0; i 0 while(sc.hasNext()) {
			a[i] = sc.nextInt();
			i++;
		} sc.hasNext() sc.hasNext sc {
			a[i] = sc.nextInt();
			i++;
		} a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc i++ i Arrays.sort(a, Collections.reverseOrder()) Arrays.sort Arrays a Collections.reverseOrder() Collections.reverseOrder Collections int Alice = 0; Alice 0 int Bob = 0; Bob 0 int diff = 0; diff 0 for(int j=0; j<a.length; j++) {
			if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			}
		} int j=0; int j=0; j 0 j<a.length j a.length a a.length j++ j++ j {
			if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			}
		} {
			if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			}
		} if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			} j % 2 == 0 j % 2 j 2 0 {
				Alice += a[j];
			} Alice += a[j] Alice a[j] a j {
				Bob += a[j];
			} Bob += a[j] Bob a[j] a j diff = Alice - Bob diff Alice - Bob Alice Bob System.out.println(diff) System.out.println System.out System System.out diff String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] a = new Integer[n];

		int i = 0;
		while(sc.hasNext()) {
			a[i] = sc.nextInt();
			i++;
		}

		Arrays.sort(a, Collections.reverseOrder());

		int Alice = 0;
		int Bob = 0;
		int diff = 0;
		for(int j=0; j<a.length; j++) {
			if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			}
		}
		diff = Alice - Bob;
		System.out.println(diff);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] a = new Integer[n];

		int i = 0;
		while(sc.hasNext()) {
			a[i] = sc.nextInt();
			i++;
		}

		Arrays.sort(a, Collections.reverseOrder());

		int Alice = 0;
		int Bob = 0;
		int diff = 0;
		for(int j=0; j<a.length; j++) {
			if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			}
		}
		diff = Alice - Bob;
		System.out.println(diff);
	}
} 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();
		Integer[] a = new Integer[n];

		int i = 0;
		while(sc.hasNext()) {
			a[i] = sc.nextInt();
			i++;
		}

		Arrays.sort(a, Collections.reverseOrder());

		int Alice = 0;
		int Bob = 0;
		int diff = 0;
		for(int j=0; j<a.length; j++) {
			if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			}
		}
		diff = Alice - Bob;
		System.out.println(diff);
	}
}
