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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int i = 0;
		int Alice = 0;
		int Bob = 0;
		for(i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		for(i = 1; i <= n; i++) {
			if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			}
		}
		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 scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int i = 0;
		int Alice = 0;
		int Bob = 0;
		for(i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		for(i = 1; i <= n; i++) {
			if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			}
		}
		System.out.println(Alice - Bob);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int i = 0;
		int Alice = 0;
		int Bob = 0;
		for(i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		for(i = 1; i <= n; i++) {
			if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			}
		}
		System.out.println(Alice - Bob);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int i = 0;
		int Alice = 0;
		int Bob = 0;
		for(i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		for(i = 1; i <= n; i++) {
			if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			}
		}
		System.out.println(Alice - Bob);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] a = new int[n]; a new int[n] n int i = 0; i 0 int Alice = 0; Alice 0 int Bob = 0; Bob 0 for(i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		} i = 0; i = 0 i 0 i < n i n i++ i++ i {
			a[i] = scan.nextInt();
		} {
			a[i] = scan.nextInt();
		} a[i] = scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan Arrays.sort(a) Arrays.sort Arrays a for(i = 1; i <= n; i++) {
			if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			}
		} i = 1; i = 1 i 1 i <= n i n i++ i++ i {
			if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			}
		} {
			if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			}
		} if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			} i % 2 == 1 i % 2 i 2 1 {
				Alice = Alice + a[n - i];
			} Alice = Alice + a[n - i] Alice Alice + a[n - i] Alice a[n - i] a n - i n i {
				Bob = Bob + a[n - i];
			} Bob = Bob + a[n - i] Bob Bob + a[n - i] Bob a[n - i] a n - i n i 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 scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int i = 0;
		int Alice = 0;
		int Bob = 0;
		for(i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		for(i = 1; i <= n; i++) {
			if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			}
		}
		System.out.println(Alice - Bob);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int i = 0;
		int Alice = 0;
		int Bob = 0;
		for(i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		for(i = 1; i <= n; i++) {
			if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			}
		}
		System.out.println(Alice - Bob);
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int i = 0;
		int Alice = 0;
		int Bob = 0;
		for(i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		for(i = 1; i <= n; i++) {
			if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			}
		}
		System.out.println(Alice - Bob);
	}
}