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