import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> A = new ArrayList<>();
		int aliceSum = 0, bobSum = 0;

		for (int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		}

		Collections.sort(A);
		Collections.reverse(A);

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			}
		}

		System.out.println(aliceSum - bobSum);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List 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();
		List<Integer> A = new ArrayList<>();
		int aliceSum = 0, bobSum = 0;

		for (int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		}

		Collections.sort(A);
		Collections.reverse(A);

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			}
		}

		System.out.println(aliceSum - bobSum);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> A = new ArrayList<>();
		int aliceSum = 0, bobSum = 0;

		for (int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		}

		Collections.sort(A);
		Collections.reverse(A);

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			}
		}

		System.out.println(aliceSum - bobSum);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> A = new ArrayList<>();
		int aliceSum = 0, bobSum = 0;

		for (int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		}

		Collections.sort(A);
		Collections.reverse(A);

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			}
		}

		System.out.println(aliceSum - bobSum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc List<Integer> A = new ArrayList<>(); A new ArrayList<>() int aliceSum = 0 aliceSum 0 bobSum = 0; bobSum 0 for (int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			A.add(sc.nextInt());
		} {
			A.add(sc.nextInt());
		} A.add(sc.nextInt()) A.add A sc.nextInt() sc.nextInt sc Collections.sort(A) Collections.sort Collections A Collections.reverse(A) Collections.reverse Collections A for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			}
		} {
			if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			}
		} if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			} i % 2 == 0 i % 2 i 2 0 {
				aliceSum += A.get(i);
			} aliceSum += A.get(i) aliceSum A.get(i) A.get A i {
				bobSum += A.get(i);
			} bobSum += A.get(i) bobSum A.get(i) A.get A i System.out.println(aliceSum - bobSum) System.out.println System.out System System.out aliceSum - bobSum aliceSum bobSum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> A = new ArrayList<>();
		int aliceSum = 0, bobSum = 0;

		for (int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		}

		Collections.sort(A);
		Collections.reverse(A);

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			}
		}

		System.out.println(aliceSum - bobSum);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> A = new ArrayList<>();
		int aliceSum = 0, bobSum = 0;

		for (int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		}

		Collections.sort(A);
		Collections.reverse(A);

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			}
		}

		System.out.println(aliceSum - bobSum);
	}
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> A = new ArrayList<>();
		int aliceSum = 0, bobSum = 0;

		for (int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		}

		Collections.sort(A);
		Collections.reverse(A);

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			}
		}

		System.out.println(aliceSum - bobSum);
	}
}
