

import java.util.Arrays;
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 = new int[n];
		int sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		int sumA = 0;

		Arrays.sort(a);

		for (int i = n - 1; i >= 0; i -= 2) {
			sumA += a[i];
		}

		System.out.println(2 * sumA - sum);
	}

} import java.util.Arrays; Arrays 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 = new int[n];
		int sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		int sumA = 0;

		Arrays.sort(a);

		for (int i = n - 1; i >= 0; i -= 2) {
			sumA += a[i];
		}

		System.out.println(2 * sumA - sum);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];
		int sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		int sumA = 0;

		Arrays.sort(a);

		for (int i = n - 1; i >= 0; i -= 2) {
			sumA += a[i];
		}

		System.out.println(2 * sumA - sum);
	} main {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];
		int sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		int sumA = 0;

		Arrays.sort(a);

		for (int i = n - 1; i >= 0; i -= 2) {
			sumA += a[i];
		}

		System.out.println(2 * sumA - sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] a = new int[n]; a new int[n] n int sum = 0; sum 0 for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			a[i] = sc.nextInt();
			sum += a[i];
		} {
			a[i] = sc.nextInt();
			sum += a[i];
		} a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc sum += a[i] sum a[i] a i int sumA = 0; sumA 0 Arrays.sort(a) Arrays.sort Arrays a for (int i = n - 1; i >= 0; i -= 2) {
			sumA += a[i];
		} int i = n - 1; int i = n - 1; i n - 1 n 1 i >= 0 i 0 i -= 2 i -= 2 i 2 {
			sumA += a[i];
		} {
			sumA += a[i];
		} sumA += a[i] sumA a[i] a i System.out.println(2 * sumA - sum) System.out.println System.out System System.out 2 * sumA - sum 2 * sumA 2 sumA sum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];
		int sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		int sumA = 0;

		Arrays.sort(a);

		for (int i = n - 1; i >= 0; i -= 2) {
			sumA += a[i];
		}

		System.out.println(2 * sumA - sum);
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];
		int sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		int sumA = 0;

		Arrays.sort(a);

		for (int i = n - 1; i >= 0; i -= 2) {
			sumA += a[i];
		}

		System.out.println(2 * sumA - sum);
	}

} Main


import java.util.Arrays;
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 = new int[n];
		int sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		int sumA = 0;

		Arrays.sort(a);

		for (int i = n - 1; i >= 0; i -= 2) {
			sumA += a[i];
		}

		System.out.println(2 * sumA - sum);
	}

}
