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

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] cards = new int[N];
		for (int i = 0; i < cards.length; i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int aliceSum = 0;
		int bobSum = 0;
		for (int i = cards.length - 1; i >= 0; i--) {
			if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			}
		}
		System.out.println(aliceSum - bobSum);
		sc.close();
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] cards = new int[N];
		for (int i = 0; i < cards.length; i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int aliceSum = 0;
		int bobSum = 0;
		for (int i = cards.length - 1; i >= 0; i--) {
			if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			}
		}
		System.out.println(aliceSum - bobSum);
		sc.close();
	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] cards = new int[N];
		for (int i = 0; i < cards.length; i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int aliceSum = 0;
		int bobSum = 0;
		for (int i = cards.length - 1; i >= 0; i--) {
			if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			}
		}
		System.out.println(aliceSum - bobSum);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] cards = new int[N];
		for (int i = 0; i < cards.length; i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int aliceSum = 0;
		int bobSum = 0;
		for (int i = cards.length - 1; i >= 0; i--) {
			if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			}
		}
		System.out.println(aliceSum - bobSum);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] cards = new int[N]; cards new int[N] N for (int i = 0; i < cards.length; i++) {
			cards[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < cards.length i cards.length cards cards.length i++ i++ i {
			cards[i] = sc.nextInt();
		} {
			cards[i] = sc.nextInt();
		} cards[i] = sc.nextInt() cards[i] cards i sc.nextInt() sc.nextInt sc Arrays.sort(cards) Arrays.sort Arrays cards int aliceSum = 0; aliceSum 0 int bobSum = 0; bobSum 0 for (int i = cards.length - 1; i >= 0; i--) {
			if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			}
		} int i = cards.length - 1; int i = cards.length - 1; i cards.length - 1 cards.length cards cards.length 1 i >= 0 i 0 i-- i-- i {
			if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			}
		} {
			if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			}
		} if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			} (cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0) (cards.length % 2 == 0 && i % 2 != 0) cards.length % 2 == 0 cards.length % 2 cards.length cards cards.length 2 0 i % 2 != 0 i % 2 i 2 0 (cards.length % 2 != 0 && i % 2 == 0) cards.length % 2 != 0 cards.length % 2 cards.length cards cards.length 2 0 i % 2 == 0 i % 2 i 2 0 {
				aliceSum += cards[i];
			} aliceSum += cards[i] aliceSum cards[i] cards i {
				bobSum += cards[i];
			} bobSum += cards[i] bobSum cards[i] cards i System.out.println(aliceSum - bobSum) System.out.println System.out System System.out aliceSum - bobSum aliceSum bobSum sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] cards = new int[N];
		for (int i = 0; i < cards.length; i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int aliceSum = 0;
		int bobSum = 0;
		for (int i = cards.length - 1; i >= 0; i--) {
			if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			}
		}
		System.out.println(aliceSum - bobSum);
		sc.close();
	}
} public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] cards = new int[N];
		for (int i = 0; i < cards.length; i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int aliceSum = 0;
		int bobSum = 0;
		for (int i = cards.length - 1; i >= 0; i--) {
			if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			}
		}
		System.out.println(aliceSum - bobSum);
		sc.close();
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] cards = new int[N];
		for (int i = 0; i < cards.length; i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int aliceSum = 0;
		int bobSum = 0;
		for (int i = cards.length - 1; i >= 0; i--) {
			if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			}
		}
		System.out.println(aliceSum - bobSum);
		sc.close();
	}
}