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[] input = new int[N];
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextInt();
		}
		Arrays.sort(input);
		long aSum = 0;
		long bSum = 0;
		boolean flg = true;
		for (int i = N - 1; i >= 0; i--) {
			if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			}
		}
		System.out.println(aSum - bSum);

	}
} 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[] input = new int[N];
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextInt();
		}
		Arrays.sort(input);
		long aSum = 0;
		long bSum = 0;
		boolean flg = true;
		for (int i = N - 1; i >= 0; i--) {
			if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			}
		}
		System.out.println(aSum - bSum);

	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] input = new int[N];
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextInt();
		}
		Arrays.sort(input);
		long aSum = 0;
		long bSum = 0;
		boolean flg = true;
		for (int i = N - 1; i >= 0; i--) {
			if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			}
		}
		System.out.println(aSum - bSum);

	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] input = new int[N];
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextInt();
		}
		Arrays.sort(input);
		long aSum = 0;
		long bSum = 0;
		boolean flg = true;
		for (int i = N - 1; i >= 0; i--) {
			if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			}
		}
		System.out.println(aSum - bSum);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] input = new int[N]; input new int[N] N for (int i = 0; i < N; i++) {
			input[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			input[i] = sc.nextInt();
		} {
			input[i] = sc.nextInt();
		} input[i] = sc.nextInt() input[i] input i sc.nextInt() sc.nextInt sc Arrays.sort(input) Arrays.sort Arrays input long aSum = 0; aSum 0 long bSum = 0; bSum 0 boolean flg = true; flg true for (int i = N - 1; i >= 0; i--) {
			if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			}
		} int i = N - 1; int i = N - 1; i N - 1 N 1 i >= 0 i 0 i-- i-- i {
			if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			}
		} {
			if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			}
		} if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			} flg {
				aSum += input[i];
				flg = !flg;
			} aSum += input[i] aSum input[i] input i flg = !flg flg !flg flg {
				bSum += input[i];
				flg = !flg;
			} bSum += input[i] bSum input[i] input i flg = !flg flg !flg flg System.out.println(aSum - bSum) System.out.println System.out System System.out aSum - bSum aSum bSum 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[] input = new int[N];
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextInt();
		}
		Arrays.sort(input);
		long aSum = 0;
		long bSum = 0;
		boolean flg = true;
		for (int i = N - 1; i >= 0; i--) {
			if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			}
		}
		System.out.println(aSum - bSum);

	}
} public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] input = new int[N];
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextInt();
		}
		Arrays.sort(input);
		long aSum = 0;
		long bSum = 0;
		boolean flg = true;
		for (int i = N - 1; i >= 0; i--) {
			if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			}
		}
		System.out.println(aSum - bSum);

	}
} 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[] input = new int[N];
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextInt();
		}
		Arrays.sort(input);
		long aSum = 0;
		long bSum = 0;
		boolean flg = true;
		for (int i = N - 1; i >= 0; i--) {
			if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			}
		}
		System.out.println(aSum - bSum);

	}
}
