import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int N;
	int A[];
	public void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = new int[N];
		for(int i=0; i<N; i++) A[i] = sc.nextInt();
		Arrays.sort(A);

		int a = 0;
		int b = 0;
		for(int i=0; i<N; i++) {
			if(i%2==0) a += A[N-i-1];
			else b += A[N-i-1];
		}
		System.out.println(a-b);
		sc.close();
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int N;
	int A[];
	public void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = new int[N];
		for(int i=0; i<N; i++) A[i] = sc.nextInt();
		Arrays.sort(A);

		int a = 0;
		int b = 0;
		for(int i=0; i<N; i++) {
			if(i%2==0) a += A[N-i-1];
			else b += A[N-i-1];
		}
		System.out.println(a-b);
		sc.close();
	}
} Main int N; N int A[]; A public static void main(String[] args) {
		Main main = new Main();
		main.run();
	} main {
		Main main = new Main();
		main.run();
	} Main main = new Main(); main new Main() main.run() main.run main String[] args args public void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = new int[N];
		for(int i=0; i<N; i++) A[i] = sc.nextInt();
		Arrays.sort(A);

		int a = 0;
		int b = 0;
		for(int i=0; i<N; i++) {
			if(i%2==0) a += A[N-i-1];
			else b += A[N-i-1];
		}
		System.out.println(a-b);
		sc.close();
	} run {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = new int[N];
		for(int i=0; i<N; i++) A[i] = sc.nextInt();
		Arrays.sort(A);

		int a = 0;
		int b = 0;
		for(int i=0; i<N; i++) {
			if(i%2==0) a += A[N-i-1];
			else b += A[N-i-1];
		}
		System.out.println(a-b);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) N = sc.nextInt() N sc.nextInt() sc.nextInt sc A = new int[N] A new int[N] N for(int i=0; i<N; i++) A[i] = sc.nextInt(); int i=0; int i=0; i 0 i<N i N i++ i++ i A[i] = sc.nextInt(); A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc Arrays.sort(A) Arrays.sort Arrays A int a = 0; a 0 int b = 0; b 0 for(int i=0; i<N; i++) {
			if(i%2==0) a += A[N-i-1];
			else b += A[N-i-1];
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			if(i%2==0) a += A[N-i-1];
			else b += A[N-i-1];
		} {
			if(i%2==0) a += A[N-i-1];
			else b += A[N-i-1];
		} if(i%2==0) a += A[N-i-1];
			else b += A[N-i-1]; i%2==0 i%2 i 2 0 a += A[N-i-1] a A[N-i-1] A N-i-1 N-i-1 N i 1 b += A[N-i-1] b A[N-i-1] A N-i-1 N-i-1 N i 1 System.out.println(a-b) System.out.println System.out System System.out a-b a b sc.close() sc.close sc public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int N;
	int A[];
	public void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = new int[N];
		for(int i=0; i<N; i++) A[i] = sc.nextInt();
		Arrays.sort(A);

		int a = 0;
		int b = 0;
		for(int i=0; i<N; i++) {
			if(i%2==0) a += A[N-i-1];
			else b += A[N-i-1];
		}
		System.out.println(a-b);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int N;
	int A[];
	public void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = new int[N];
		for(int i=0; i<N; i++) A[i] = sc.nextInt();
		Arrays.sort(A);

		int a = 0;
		int b = 0;
		for(int i=0; i<N; i++) {
			if(i%2==0) a += A[N-i-1];
			else b += A[N-i-1];
		}
		System.out.println(a-b);
		sc.close();
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int N;
	int A[];
	public void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = new int[N];
		for(int i=0; i<N; i++) A[i] = sc.nextInt();
		Arrays.sort(A);

		int a = 0;
		int b = 0;
		for(int i=0; i<N; i++) {
			if(i%2==0) a += A[N-i-1];
			else b += A[N-i-1];
		}
		System.out.println(a-b);
		sc.close();
	}
}