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

public class Main {
	static int[][] bingo = new int[3][3];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		int alice = 0;
		int bob = 0;

		for (int i = 0; i < a.length; i++) {
			if (i % 2 == 0) {
				alice += a[a.length - 1 - i];
			} else {
				bob += a[a.length - 1 - i];
			}
		}

		System.out.println(Math.abs(alice - bob));

	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	static int[][] bingo = new int[3][3];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		int alice = 0;
		int bob = 0;

		for (int i = 0; i < a.length; i++) {
			if (i % 2 == 0) {
				alice += a[a.length - 1 - i];
			} else {
				bob += a[a.length - 1 - i];
			}
		}

		System.out.println(Math.abs(alice - bob));

	}
} Main static int[][] bingo = new int[3][3]; bingo new int[3][3] 3 3 public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		int alice = 0;
		int bob = 0;

		for (int i = 0; i < a.length; i++) {
			if (i % 2 == 0) {
				alice += a[a.length - 1 - i];
			} else {
				bob += a[a.length - 1 - i];
			}
		}

		System.out.println(Math.abs(alice - bob));

	} main {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		int alice = 0;
		int bob = 0;

		for (int i = 0; i < a.length; i++) {
			if (i % 2 == 0) {
				alice += a[a.length - 1 - i];
			} else {
				bob += a[a.length - 1 - i];
			}
		}

		System.out.println(Math.abs(alice - bob));

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] a = new int[n]; a new int[n] n for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			a[i] = Integer.parseInt(sc.next());
		} {
			a[i] = Integer.parseInt(sc.next());
		} a[i] = Integer.parseInt(sc.next()) a[i] a i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(a) Arrays.sort Arrays a int alice = 0; alice 0 int bob = 0; bob 0 for (int i = 0; i < a.length; i++) {
			if (i % 2 == 0) {
				alice += a[a.length - 1 - i];
			} else {
				bob += a[a.length - 1 - i];
			}
		} int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {
			if (i % 2 == 0) {
				alice += a[a.length - 1 - i];
			} else {
				bob += a[a.length - 1 - i];
			}
		} {
			if (i % 2 == 0) {
				alice += a[a.length - 1 - i];
			} else {
				bob += a[a.length - 1 - i];
			}
		} if (i % 2 == 0) {
				alice += a[a.length - 1 - i];
			} else {
				bob += a[a.length - 1 - i];
			} i % 2 == 0 i % 2 i 2 0 {
				alice += a[a.length - 1 - i];
			} alice += a[a.length - 1 - i] alice a[a.length - 1 - i] a a.length - 1 - i a.length - 1 - i a.length a a.length 1 i {
				bob += a[a.length - 1 - i];
			} bob += a[a.length - 1 - i] bob a[a.length - 1 - i] a a.length - 1 - i a.length - 1 - i a.length a a.length 1 i System.out.println(Math.abs(alice - bob)) System.out.println System.out System System.out Math.abs(alice - bob) Math.abs Math alice - bob alice bob String[] args args public class Main {
	static int[][] bingo = new int[3][3];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		int alice = 0;
		int bob = 0;

		for (int i = 0; i < a.length; i++) {
			if (i % 2 == 0) {
				alice += a[a.length - 1 - i];
			} else {
				bob += a[a.length - 1 - i];
			}
		}

		System.out.println(Math.abs(alice - bob));

	}
} public class Main {
	static int[][] bingo = new int[3][3];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		int alice = 0;
		int bob = 0;

		for (int i = 0; i < a.length; i++) {
			if (i % 2 == 0) {
				alice += a[a.length - 1 - i];
			} else {
				bob += a[a.length - 1 - i];
			}
		}

		System.out.println(Math.abs(alice - bob));

	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int[][] bingo = new int[3][3];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		int alice = 0;
		int bob = 0;

		for (int i = 0; i < a.length; i++) {
			if (i % 2 == 0) {
				alice += a[a.length - 1 - i];
			} else {
				bob += a[a.length - 1 - i];
			}
		}

		System.out.println(Math.abs(alice - bob));

	}
}
