import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		Integer[] a = new Integer[N];
		for(int i = 0; i < N; i++) {
			a[i] = stdIn.nextInt();
		}
		Arrays.sort(a, Collections.reverseOrder());
		
		int A = 0;
		int B = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) A += a[i];
			else B += a[i];
		}
		System.out.println(A-B);

	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		Integer[] a = new Integer[N];
		for(int i = 0; i < N; i++) {
			a[i] = stdIn.nextInt();
		}
		Arrays.sort(a, Collections.reverseOrder());
		
		int A = 0;
		int B = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) A += a[i];
			else B += a[i];
		}
		System.out.println(A-B);

	}

} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		Integer[] a = new Integer[N];
		for(int i = 0; i < N; i++) {
			a[i] = stdIn.nextInt();
		}
		Arrays.sort(a, Collections.reverseOrder());
		
		int A = 0;
		int B = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) A += a[i];
			else B += a[i];
		}
		System.out.println(A-B);

	} main {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		Integer[] a = new Integer[N];
		for(int i = 0; i < N; i++) {
			a[i] = stdIn.nextInt();
		}
		Arrays.sort(a, Collections.reverseOrder());
		
		int A = 0;
		int B = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) A += a[i];
			else B += a[i];
		}
		System.out.println(A-B);

	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int N = stdIn.nextInt(); N stdIn.nextInt() stdIn.nextInt stdIn Integer[] a = new Integer[N]; a new Integer[N] N for(int i = 0; i < N; i++) {
			a[i] = stdIn.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			a[i] = stdIn.nextInt();
		} {
			a[i] = stdIn.nextInt();
		} a[i] = stdIn.nextInt() a[i] a i stdIn.nextInt() stdIn.nextInt stdIn Arrays.sort(a, Collections.reverseOrder()) Arrays.sort Arrays a Collections.reverseOrder() Collections.reverseOrder Collections int A = 0; A 0 int B = 0; B 0 for(int i = 0; i < N; i++) {
			if(i%2 == 0) A += a[i];
			else B += a[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if(i%2 == 0) A += a[i];
			else B += a[i];
		} {
			if(i%2 == 0) A += a[i];
			else B += a[i];
		} if(i%2 == 0) A += a[i];
			else B += a[i]; i%2 == 0 i%2 i 2 0 A += a[i] A a[i] a i B += a[i] B a[i] a i 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 stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		Integer[] a = new Integer[N];
		for(int i = 0; i < N; i++) {
			a[i] = stdIn.nextInt();
		}
		Arrays.sort(a, Collections.reverseOrder());
		
		int A = 0;
		int B = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) A += a[i];
			else B += a[i];
		}
		System.out.println(A-B);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		Integer[] a = new Integer[N];
		for(int i = 0; i < N; i++) {
			a[i] = stdIn.nextInt();
		}
		Arrays.sort(a, Collections.reverseOrder());
		
		int A = 0;
		int B = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) A += a[i];
			else B += a[i];
		}
		System.out.println(A-B);

	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		Integer[] a = new Integer[N];
		for(int i = 0; i < N; i++) {
			a[i] = stdIn.nextInt();
		}
		Arrays.sort(a, Collections.reverseOrder());
		
		int A = 0;
		int B = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) A += a[i];
			else B += a[i];
		}
		System.out.println(A-B);

	}

}