import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int N, sumA, sumB;
		sumA = 0; sumB = 0;
		Scanner input = new Scanner(System.in);
		N = input.nextInt();
		int[] a = new int[N];
		
		for(int i=0; i < N; i++) {
			a[i] = input.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			}
		}
		
		for(int i = 0; i < N; i+=2) {
			sumA += a[i];
		}
		for(int i = 1; i < N; i+=2) {
			sumB += a[i];
		}
		
		System.out.println(sumA - sumB);
		
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		int N, sumA, sumB;
		sumA = 0; sumB = 0;
		Scanner input = new Scanner(System.in);
		N = input.nextInt();
		int[] a = new int[N];
		
		for(int i=0; i < N; i++) {
			a[i] = input.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			}
		}
		
		for(int i = 0; i < N; i+=2) {
			sumA += a[i];
		}
		for(int i = 1; i < N; i+=2) {
			sumB += a[i];
		}
		
		System.out.println(sumA - sumB);
		
	}

} Main public static void main(String[] args) {
		int N, sumA, sumB;
		sumA = 0; sumB = 0;
		Scanner input = new Scanner(System.in);
		N = input.nextInt();
		int[] a = new int[N];
		
		for(int i=0; i < N; i++) {
			a[i] = input.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			}
		}
		
		for(int i = 0; i < N; i+=2) {
			sumA += a[i];
		}
		for(int i = 1; i < N; i+=2) {
			sumB += a[i];
		}
		
		System.out.println(sumA - sumB);
		
	} main {
		int N, sumA, sumB;
		sumA = 0; sumB = 0;
		Scanner input = new Scanner(System.in);
		N = input.nextInt();
		int[] a = new int[N];
		
		for(int i=0; i < N; i++) {
			a[i] = input.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			}
		}
		
		for(int i = 0; i < N; i+=2) {
			sumA += a[i];
		}
		for(int i = 1; i < N; i+=2) {
			sumB += a[i];
		}
		
		System.out.println(sumA - sumB);
		
	} int N N sumA sumA sumB; sumB sumA = 0 sumA 0 sumB = 0 sumB 0 Scanner input = new Scanner(System.in); input new Scanner(System.in) N = input.nextInt() N input.nextInt() input.nextInt input int[] a = new int[N]; a new int[N] N for(int i=0; i < N; i++) {
			a[i] = input.nextInt();
		} int i=0; int i=0; i 0 i < N i N i++ i++ i {
			a[i] = input.nextInt();
		} {
			a[i] = input.nextInt();
		} a[i] = input.nextInt() a[i] a i input.nextInt() input.nextInt input for(int i = 0; i < N; i++) {
			for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			}
		} {
			for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			}
		} for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			} int t = 0; int t = 0; t 0 t < N t N t++ t++ t {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			} {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			} if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				} a[i]>a[t] a[i] a i a[t] a t {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				} int temp = a[i]; temp a[i] a i a[i] = a[t] a[i] a i a[t] a t a[t] = temp a[t] a t temp for(int i = 0; i < N; i+=2) {
			sumA += a[i];
		} int i = 0; int i = 0; i 0 i < N i N i+=2 i+=2 i 2 {
			sumA += a[i];
		} {
			sumA += a[i];
		} sumA += a[i] sumA a[i] a i for(int i = 1; i < N; i+=2) {
			sumB += a[i];
		} int i = 1; int i = 1; i 1 i < N i N i+=2 i+=2 i 2 {
			sumB += a[i];
		} {
			sumB += a[i];
		} sumB += a[i] sumB a[i] a i System.out.println(sumA - sumB) System.out.println System.out System System.out sumA - sumB sumA sumB String[] args args public class Main {

	public static void main(String[] args) {
		int N, sumA, sumB;
		sumA = 0; sumB = 0;
		Scanner input = new Scanner(System.in);
		N = input.nextInt();
		int[] a = new int[N];
		
		for(int i=0; i < N; i++) {
			a[i] = input.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			}
		}
		
		for(int i = 0; i < N; i+=2) {
			sumA += a[i];
		}
		for(int i = 1; i < N; i+=2) {
			sumB += a[i];
		}
		
		System.out.println(sumA - sumB);
		
	}

} public class Main {

	public static void main(String[] args) {
		int N, sumA, sumB;
		sumA = 0; sumB = 0;
		Scanner input = new Scanner(System.in);
		N = input.nextInt();
		int[] a = new int[N];
		
		for(int i=0; i < N; i++) {
			a[i] = input.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			}
		}
		
		for(int i = 0; i < N; i+=2) {
			sumA += a[i];
		}
		for(int i = 1; i < N; i+=2) {
			sumB += a[i];
		}
		
		System.out.println(sumA - sumB);
		
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int N, sumA, sumB;
		sumA = 0; sumB = 0;
		Scanner input = new Scanner(System.in);
		N = input.nextInt();
		int[] a = new int[N];
		
		for(int i=0; i < N; i++) {
			a[i] = input.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			}
		}
		
		for(int i = 0; i < N; i+=2) {
			sumA += a[i];
		}
		for(int i = 1; i < N; i+=2) {
			sumB += a[i];
		}
		
		System.out.println(sumA - sumB);
		
	}

}
