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

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] arr = new int[N];
		int a = 0;
		int b = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = reader.nextInt();
		}
		Arrays.sort(arr);
		for (int i = N-1; i >= 0; i-=2) {
			a += arr[i];
			if (i > 0) {
				b += arr[i-1];
			}
		}


		System.out.print(a-b);
		reader.close();
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] arr = new int[N];
		int a = 0;
		int b = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = reader.nextInt();
		}
		Arrays.sort(arr);
		for (int i = N-1; i >= 0; i-=2) {
			a += arr[i];
			if (i > 0) {
				b += arr[i-1];
			}
		}


		System.out.print(a-b);
		reader.close();
	}
} Main public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] arr = new int[N];
		int a = 0;
		int b = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = reader.nextInt();
		}
		Arrays.sort(arr);
		for (int i = N-1; i >= 0; i-=2) {
			a += arr[i];
			if (i > 0) {
				b += arr[i-1];
			}
		}


		System.out.print(a-b);
		reader.close();
	} main {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] arr = new int[N];
		int a = 0;
		int b = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = reader.nextInt();
		}
		Arrays.sort(arr);
		for (int i = N-1; i >= 0; i-=2) {
			a += arr[i];
			if (i > 0) {
				b += arr[i-1];
			}
		}


		System.out.print(a-b);
		reader.close();
	} Scanner reader = new Scanner(System.in); reader new Scanner(System.in) int N = reader.nextInt(); N reader.nextInt() reader.nextInt reader int[] arr = new int[N]; arr new int[N] N int a = 0; a 0 int b = 0; b 0 for (int i = 0; i < N; i++) {
			arr[i] = reader.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			arr[i] = reader.nextInt();
		} {
			arr[i] = reader.nextInt();
		} arr[i] = reader.nextInt() arr[i] arr i reader.nextInt() reader.nextInt reader Arrays.sort(arr) Arrays.sort Arrays arr for (int i = N-1; i >= 0; i-=2) {
			a += arr[i];
			if (i > 0) {
				b += arr[i-1];
			}
		} int i = N-1; int i = N-1; i N-1 N 1 i >= 0 i 0 i-=2 i-=2 i 2 {
			a += arr[i];
			if (i > 0) {
				b += arr[i-1];
			}
		} {
			a += arr[i];
			if (i > 0) {
				b += arr[i-1];
			}
		} a += arr[i] a arr[i] arr i if (i > 0) {
				b += arr[i-1];
			} i > 0 i 0 {
				b += arr[i-1];
			} b += arr[i-1] b arr[i-1] arr i-1 i 1 System.out.print(a-b) System.out.print System.out System System.out a-b a b reader.close() reader.close reader String[] args args public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] arr = new int[N];
		int a = 0;
		int b = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = reader.nextInt();
		}
		Arrays.sort(arr);
		for (int i = N-1; i >= 0; i-=2) {
			a += arr[i];
			if (i > 0) {
				b += arr[i-1];
			}
		}


		System.out.print(a-b);
		reader.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] arr = new int[N];
		int a = 0;
		int b = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = reader.nextInt();
		}
		Arrays.sort(arr);
		for (int i = N-1; i >= 0; i-=2) {
			a += arr[i];
			if (i > 0) {
				b += arr[i-1];
			}
		}


		System.out.print(a-b);
		reader.close();
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] arr = new int[N];
		int a = 0;
		int b = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = reader.nextInt();
		}
		Arrays.sort(arr);
		for (int i = N-1; i >= 0; i-=2) {
			a += arr[i];
			if (i > 0) {
				b += arr[i-1];
			}
		}


		System.out.print(a-b);
		reader.close();
	}
}