import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), i=0, no=N, p=0, q=0;
		int[] a = new int[N];
		boolean f = true;
		while (no-->0) a[i++] = sc.nextInt();
		Arrays.sort(a);
		for (i=N-1; i>=0; i--) {
			if (f) p+=a[i];
			else q+=a[i];
			f=!f;
		}
		System.out.println(p-q);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

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

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), i=0, no=N, p=0, q=0;
		int[] a = new int[N];
		boolean f = true;
		while (no-->0) a[i++] = sc.nextInt();
		Arrays.sort(a);
		for (i=N-1; i>=0; i--) {
			if (f) p+=a[i];
			else q+=a[i];
			f=!f;
		}
		System.out.println(p-q);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

} Main static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), i=0, no=N, p=0, q=0;
		int[] a = new int[N];
		boolean f = true;
		while (no-->0) a[i++] = sc.nextInt();
		Arrays.sort(a);
		for (i=N-1; i>=0; i--) {
			if (f) p+=a[i];
			else q+=a[i];
			f=!f;
		}
		System.out.println(p-q);
		sc.close();		
	} solve {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), i=0, no=N, p=0, q=0;
		int[] a = new int[N];
		boolean f = true;
		while (no-->0) a[i++] = sc.nextInt();
		Arrays.sort(a);
		for (i=N-1; i>=0; i--) {
			if (f) p+=a[i];
			else q+=a[i];
			f=!f;
		}
		System.out.println(p-q);
		sc.close();		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt() N sc.nextInt() sc.nextInt sc i=0 i 0 no=N no N p=0 p 0 q=0; q 0 int[] a = new int[N]; a new int[N] N boolean f = true; f true while (no-->0) a[i++] = sc.nextInt(); no-->0 no-- no 0 a[i++] = sc.nextInt() a[i++] a i++ i sc.nextInt() sc.nextInt sc Arrays.sort(a) Arrays.sort Arrays a for (i=N-1; i>=0; i--) {
			if (f) p+=a[i];
			else q+=a[i];
			f=!f;
		} i=N-1; i=N-1 i N-1 N 1 i>=0 i 0 i-- i-- i {
			if (f) p+=a[i];
			else q+=a[i];
			f=!f;
		} {
			if (f) p+=a[i];
			else q+=a[i];
			f=!f;
		} if (f) p+=a[i];
			else q+=a[i]; f p+=a[i] p a[i] a i q+=a[i] q a[i] a i f=!f f !f f System.out.println(p-q) System.out.println System.out System System.out p-q p q sc.close() sc.close sc public static void main(String args[]) {
		solve();
	} main {
		solve();
	} solve() solve String args[] args public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), i=0, no=N, p=0, q=0;
		int[] a = new int[N];
		boolean f = true;
		while (no-->0) a[i++] = sc.nextInt();
		Arrays.sort(a);
		for (i=N-1; i>=0; i--) {
			if (f) p+=a[i];
			else q+=a[i];
			f=!f;
		}
		System.out.println(p-q);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

} public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), i=0, no=N, p=0, q=0;
		int[] a = new int[N];
		boolean f = true;
		while (no-->0) a[i++] = sc.nextInt();
		Arrays.sort(a);
		for (i=N-1; i>=0; i--) {
			if (f) p+=a[i];
			else q+=a[i];
			f=!f;
		}
		System.out.println(p-q);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

} Main
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), i=0, no=N, p=0, q=0;
		int[] a = new int[N];
		boolean f = true;
		while (no-->0) a[i++] = sc.nextInt();
		Arrays.sort(a);
		for (i=N-1; i>=0; i--) {
			if (f) p+=a[i];
			else q+=a[i];
			f=!f;
		}
		System.out.println(p-q);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}