import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] Array = new Integer[N];
		for(int i = 0;i < N;i++) {
			Array[i] = sc.nextInt();
		}
		Arrays.sort(Array,Collections.reverseOrder());
		int A = 0,B = 0;
		for(int k = 0;k < N;k++) {
			if(k % 2 == 0) A += Array[k];
			else B += Array[k];
		}
		int ans = A - B;
		System.out.println(ans);
		sc.close();
	}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] Array = new Integer[N];
		for(int i = 0;i < N;i++) {
			Array[i] = sc.nextInt();
		}
		Arrays.sort(Array,Collections.reverseOrder());
		int A = 0,B = 0;
		for(int k = 0;k < N;k++) {
			if(k % 2 == 0) A += Array[k];
			else B += Array[k];
		}
		int ans = A - B;
		System.out.println(ans);
		sc.close();
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] Array = new Integer[N];
		for(int i = 0;i < N;i++) {
			Array[i] = sc.nextInt();
		}
		Arrays.sort(Array,Collections.reverseOrder());
		int A = 0,B = 0;
		for(int k = 0;k < N;k++) {
			if(k % 2 == 0) A += Array[k];
			else B += Array[k];
		}
		int ans = A - B;
		System.out.println(ans);
		sc.close();
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] Array = new Integer[N];
		for(int i = 0;i < N;i++) {
			Array[i] = sc.nextInt();
		}
		Arrays.sort(Array,Collections.reverseOrder());
		int A = 0,B = 0;
		for(int k = 0;k < N;k++) {
			if(k % 2 == 0) A += Array[k];
			else B += Array[k];
		}
		int ans = A - B;
		System.out.println(ans);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc Integer[] Array = new Integer[N]; Array new Integer[N] N for(int i = 0;i < N;i++) {
			Array[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			Array[i] = sc.nextInt();
		} {
			Array[i] = sc.nextInt();
		} Array[i] = sc.nextInt() Array[i] Array i sc.nextInt() sc.nextInt sc Arrays.sort(Array,Collections.reverseOrder()) Arrays.sort Arrays Array Collections.reverseOrder() Collections.reverseOrder Collections int A = 0 A 0 B = 0; B 0 for(int k = 0;k < N;k++) {
			if(k % 2 == 0) A += Array[k];
			else B += Array[k];
		} int k = 0; int k = 0; k 0 k < N k N k++ k++ k {
			if(k % 2 == 0) A += Array[k];
			else B += Array[k];
		} {
			if(k % 2 == 0) A += Array[k];
			else B += Array[k];
		} if(k % 2 == 0) A += Array[k];
			else B += Array[k]; k % 2 == 0 k % 2 k 2 0 A += Array[k] A Array[k] Array k B += Array[k] B Array[k] Array k int ans = A - B; ans A - B A B System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] Array = new Integer[N];
		for(int i = 0;i < N;i++) {
			Array[i] = sc.nextInt();
		}
		Arrays.sort(Array,Collections.reverseOrder());
		int A = 0,B = 0;
		for(int k = 0;k < N;k++) {
			if(k % 2 == 0) A += Array[k];
			else B += Array[k];
		}
		int ans = A - B;
		System.out.println(ans);
		sc.close();
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] Array = new Integer[N];
		for(int i = 0;i < N;i++) {
			Array[i] = sc.nextInt();
		}
		Arrays.sort(Array,Collections.reverseOrder());
		int A = 0,B = 0;
		for(int k = 0;k < N;k++) {
			if(k % 2 == 0) A += Array[k];
			else B += Array[k];
		}
		int ans = A - B;
		System.out.println(ans);
		sc.close();
	}

} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] Array = new Integer[N];
		for(int i = 0;i < N;i++) {
			Array[i] = sc.nextInt();
		}
		Arrays.sort(Array,Collections.reverseOrder());
		int A = 0,B = 0;
		for(int k = 0;k < N;k++) {
			if(k % 2 == 0) A += Array[k];
			else B += Array[k];
		}
		int ans = A - B;
		System.out.println(ans);
		sc.close();
	}

}
