	import java.util.*;
	
	
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			Integer a[] = new Integer[N];
			for (int i =0;i<N;i++) {
				a[i] = sc.nextInt();
			}
			Arrays.sort(a,Collections.reverseOrder());
			
			int sumAlice = 0;
			int sumBob = 0;
			
			for (int j=0;j<N;j++) {
				if (j%2 == 0) {
					sumAlice += a[j];
				}else {
					sumBob += a[j];
				}
			}
			
			int res = sumAlice - sumBob;
			
			System.out.println(res);
		}
		
		
	} import java.util.*; util.* java public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			Integer a[] = new Integer[N];
			for (int i =0;i<N;i++) {
				a[i] = sc.nextInt();
			}
			Arrays.sort(a,Collections.reverseOrder());
			
			int sumAlice = 0;
			int sumBob = 0;
			
			for (int j=0;j<N;j++) {
				if (j%2 == 0) {
					sumAlice += a[j];
				}else {
					sumBob += a[j];
				}
			}
			
			int res = sumAlice - sumBob;
			
			System.out.println(res);
		}
		
		
	} Main public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			Integer a[] = new Integer[N];
			for (int i =0;i<N;i++) {
				a[i] = sc.nextInt();
			}
			Arrays.sort(a,Collections.reverseOrder());
			
			int sumAlice = 0;
			int sumBob = 0;
			
			for (int j=0;j<N;j++) {
				if (j%2 == 0) {
					sumAlice += a[j];
				}else {
					sumBob += a[j];
				}
			}
			
			int res = sumAlice - sumBob;
			
			System.out.println(res);
		} main {
		
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			Integer a[] = new Integer[N];
			for (int i =0;i<N;i++) {
				a[i] = sc.nextInt();
			}
			Arrays.sort(a,Collections.reverseOrder());
			
			int sumAlice = 0;
			int sumBob = 0;
			
			for (int j=0;j<N;j++) {
				if (j%2 == 0) {
					sumAlice += a[j];
				}else {
					sumBob += a[j];
				}
			}
			
			int res = sumAlice - sumBob;
			
			System.out.println(res);
		} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc Integer a[] = new Integer[N]; a new Integer[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,Collections.reverseOrder()) Arrays.sort Arrays a Collections.reverseOrder() Collections.reverseOrder Collections int sumAlice = 0; sumAlice 0 int sumBob = 0; sumBob 0 for (int j=0;j<N;j++) {
				if (j%2 == 0) {
					sumAlice += a[j];
				}else {
					sumBob += a[j];
				}
			} int j=0; int j=0; j 0 j<N j N j++ j++ j {
				if (j%2 == 0) {
					sumAlice += a[j];
				}else {
					sumBob += a[j];
				}
			} {
				if (j%2 == 0) {
					sumAlice += a[j];
				}else {
					sumBob += a[j];
				}
			} if (j%2 == 0) {
					sumAlice += a[j];
				}else {
					sumBob += a[j];
				} j%2 == 0 j%2 j 2 0 {
					sumAlice += a[j];
				} sumAlice += a[j] sumAlice a[j] a j {
					sumBob += a[j];
				} sumBob += a[j] sumBob a[j] a j int res = sumAlice - sumBob; res sumAlice - sumBob sumAlice sumBob System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			Integer a[] = new Integer[N];
			for (int i =0;i<N;i++) {
				a[i] = sc.nextInt();
			}
			Arrays.sort(a,Collections.reverseOrder());
			
			int sumAlice = 0;
			int sumBob = 0;
			
			for (int j=0;j<N;j++) {
				if (j%2 == 0) {
					sumAlice += a[j];
				}else {
					sumBob += a[j];
				}
			}
			
			int res = sumAlice - sumBob;
			
			System.out.println(res);
		}
		
		
	} public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			Integer a[] = new Integer[N];
			for (int i =0;i<N;i++) {
				a[i] = sc.nextInt();
			}
			Arrays.sort(a,Collections.reverseOrder());
			
			int sumAlice = 0;
			int sumBob = 0;
			
			for (int j=0;j<N;j++) {
				if (j%2 == 0) {
					sumAlice += a[j];
				}else {
					sumBob += a[j];
				}
			}
			
			int res = sumAlice - sumBob;
			
			System.out.println(res);
		}
		
		
	} Main
	import java.util.*;
	
	
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			Integer a[] = new Integer[N];
			for (int i =0;i<N;i++) {
				a[i] = sc.nextInt();
			}
			Arrays.sort(a,Collections.reverseOrder());
			
			int sumAlice = 0;
			int sumBob = 0;
			
			for (int j=0;j<N;j++) {
				if (j%2 == 0) {
					sumAlice += a[j];
				}else {
					sumBob += a[j];
				}
			}
			
			int res = sumAlice - sumBob;
			
			System.out.println(res);
		}
		
		
	}