import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Integer[] a = new Integer[N];
		for (int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int alice = 0;
		int bob = 0;
        Arrays.sort(a, Comparator.reverseOrder());
		for (int i = 0; i < N; i++) {
			if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		}
		System.out.println(alice - bob);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Integer[] a = new Integer[N];
		for (int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int alice = 0;
		int bob = 0;
        Arrays.sort(a, Comparator.reverseOrder());
		for (int i = 0; i < N; i++) {
			if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		}
		System.out.println(alice - bob);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Integer[] a = new Integer[N];
		for (int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int alice = 0;
		int bob = 0;
        Arrays.sort(a, Comparator.reverseOrder());
		for (int i = 0; i < N; i++) {
			if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		}
		System.out.println(alice - bob);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Integer[] a = new Integer[N];
		for (int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int alice = 0;
		int bob = 0;
        Arrays.sort(a, Comparator.reverseOrder());
		for (int i = 0; i < N; i++) {
			if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		}
		System.out.println(alice - bob);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Integer[] a = new Integer[N]; a new Integer[N] N for (int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			a[i] = Integer.parseInt(sc.next());
		} {
			a[i] = Integer.parseInt(sc.next());
		} a[i] = Integer.parseInt(sc.next()) a[i] a i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int alice = 0; alice 0 int bob = 0; bob 0 Arrays.sort(a, Comparator.reverseOrder()) Arrays.sort Arrays a Comparator.reverseOrder() Comparator.reverseOrder Comparator for (int i = 0; i < N; i++) {
			if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		} {
			if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		} if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			} i%2==0 i%2 i 2 0 {
				alice += a[i];
			} alice += a[i] alice a[i] a i {
				bob += a[i];
			} bob += a[i] bob a[i] a i System.out.println(alice - bob) System.out.println System.out System System.out alice - bob alice bob String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Integer[] a = new Integer[N];
		for (int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int alice = 0;
		int bob = 0;
        Arrays.sort(a, Comparator.reverseOrder());
		for (int i = 0; i < N; i++) {
			if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		}
		System.out.println(alice - bob);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Integer[] a = new Integer[N];
		for (int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int alice = 0;
		int bob = 0;
        Arrays.sort(a, Comparator.reverseOrder());
		for (int i = 0; i < N; i++) {
			if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		}
		System.out.println(alice - bob);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Integer[] a = new Integer[N];
		for (int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int alice = 0;
		int bob = 0;
        Arrays.sort(a, Comparator.reverseOrder());
		for (int i = 0; i < N; i++) {
			if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		}
		System.out.println(alice - bob);
	}
}