import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.parseLong;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		Integer[] a = new Integer[n];
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(a, Collections.reverseOrder());
		int[] ab = new int[2];
		for (i = 0; i < n; i++) {
			ab[i%2] += a[i];
		}
		out.println(ab[0]-ab[1]);
	}
} import java.util.*; util.* java import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Long.parseLong; import static java.lang.Long.parseLong; import static java.lang.Long.parseLong; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		Integer[] a = new Integer[n];
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(a, Collections.reverseOrder());
		int[] ab = new int[2];
		for (i = 0; i < n; i++) {
			ab[i%2] += a[i];
		}
		out.println(ab[0]-ab[1]);
	}
} Main public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		Integer[] a = new Integer[n];
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(a, Collections.reverseOrder());
		int[] ab = new int[2];
		for (i = 0; i < n; i++) {
			ab[i%2] += a[i];
		}
		out.println(ab[0]-ab[1]);
	} main {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		Integer[] a = new Integer[n];
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(a, Collections.reverseOrder());
		int[] ab = new int[2];
		for (i = 0; i < n; i++) {
			ab[i%2] += a[i];
		}
		out.println(ab[0]-ab[1]);
	} int i i j; j Scanner sc = new Scanner(in); sc new Scanner(in) int n = parseInt(sc.next()); n parseInt(sc.next()) parseInt sc.next() sc.next sc Integer[] a = new Integer[n]; a new Integer[n] n for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
		} i = 0; i = 0 i 0 i < n i n i++ i++ i {
			a[i] = parseInt(sc.next());
		} {
			a[i] = parseInt(sc.next());
		} a[i] = parseInt(sc.next()) a[i] a i parseInt(sc.next()) parseInt sc.next() sc.next sc sc.close() sc.close sc Arrays.sort(a, Collections.reverseOrder()) Arrays.sort Arrays a Collections.reverseOrder() Collections.reverseOrder Collections int[] ab = new int[2]; ab new int[2] 2 for (i = 0; i < n; i++) {
			ab[i%2] += a[i];
		} i = 0; i = 0 i 0 i < n i n i++ i++ i {
			ab[i%2] += a[i];
		} {
			ab[i%2] += a[i];
		} ab[i%2] += a[i] ab[i%2] ab i%2 i 2 a[i] a i out.println(ab[0]-ab[1]) out.println out ab[0]-ab[1] ab[0] ab 0 ab[1] ab 1 String[] args args public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		Integer[] a = new Integer[n];
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(a, Collections.reverseOrder());
		int[] ab = new int[2];
		for (i = 0; i < n; i++) {
			ab[i%2] += a[i];
		}
		out.println(ab[0]-ab[1]);
	}
} public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		Integer[] a = new Integer[n];
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(a, Collections.reverseOrder());
		int[] ab = new int[2];
		for (i = 0; i < n; i++) {
			ab[i%2] += a[i];
		}
		out.println(ab[0]-ab[1]);
	}
} Main
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.parseLong;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		Integer[] a = new Integer[n];
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(a, Collections.reverseOrder());
		int[] ab = new int[2];
		for (i = 0; i < n; i++) {
			ab[i%2] += a[i];
		}
		out.println(ab[0]-ab[1]);
	}
}
