import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		int a = 0;
		int b = 0;
		int cnt = 0;
		for(int i = N - 1; i >= 0; i--) {
			if(cnt % 2 == 0) {
				a += A[i];
			} else {
				b += A[i];
			}
			cnt++;
		}
		
		System.out.println(a - b);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		int a = 0;
		int b = 0;
		int cnt = 0;
		for(int i = N - 1; i >= 0; i--) {
			if(cnt % 2 == 0) {
				a += A[i];
			} else {
				b += A[i];
			}
			cnt++;
		}
		
		System.out.println(a - b);
	}
} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		int a = 0;
		int b = 0;
		int cnt = 0;
		for(int i = N - 1; i >= 0; i--) {
			if(cnt % 2 == 0) {
				a += A[i];
			} else {
				b += A[i];
			}
			cnt++;
		}
		
		System.out.println(a - b);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		int a = 0;
		int b = 0;
		int cnt = 0;
		for(int i = N - 1; i >= 0; i--) {
			if(cnt % 2 == 0) {
				a += A[i];
			} else {
				b += A[i];
			}
			cnt++;
		}
		
		System.out.println(a - b);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int A[] = new int[N]; A new int[N] N for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			A[i] = sc.nextInt();
		} {
			A[i] = sc.nextInt();
		} A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc Arrays.sort(A) Arrays.sort Arrays A int a = 0; a 0 int b = 0; b 0 int cnt = 0; cnt 0 for(int i = N - 1; i >= 0; i--) {
			if(cnt % 2 == 0) {
				a += A[i];
			} else {
				b += A[i];
			}
			cnt++;
		} int i = N - 1; int i = N - 1; i N - 1 N 1 i >= 0 i 0 i-- i-- i {
			if(cnt % 2 == 0) {
				a += A[i];
			} else {
				b += A[i];
			}
			cnt++;
		} {
			if(cnt % 2 == 0) {
				a += A[i];
			} else {
				b += A[i];
			}
			cnt++;
		} if(cnt % 2 == 0) {
				a += A[i];
			} else {
				b += A[i];
			} cnt % 2 == 0 cnt % 2 cnt 2 0 {
				a += A[i];
			} a += A[i] a A[i] A i {
				b += A[i];
			} b += A[i] b A[i] A i cnt++ cnt System.out.println(a - b) System.out.println System.out System System.out a - b a b String args[] args public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		int a = 0;
		int b = 0;
		int cnt = 0;
		for(int i = N - 1; i >= 0; i--) {
			if(cnt % 2 == 0) {
				a += A[i];
			} else {
				b += A[i];
			}
			cnt++;
		}
		
		System.out.println(a - b);
	}
} public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		int a = 0;
		int b = 0;
		int cnt = 0;
		for(int i = N - 1; i >= 0; i--) {
			if(cnt % 2 == 0) {
				a += A[i];
			} else {
				b += A[i];
			}
			cnt++;
		}
		
		System.out.println(a - b);
	}
} Main
import java.util.*;

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