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

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Integer[] point = new Integer[n];
		for (int i = 0; i < n; i++) {
			point[i] = scan.nextInt();
		}
		
		Arrays.sort(point, Collections.reverseOrder());
		
		int sum = 0;
		for (int i = 0; i + 1 < point.length; i += 2) {
			sum += point[i] - point[i + 1];
		}
		if (point.length % 2 == 1) {
			sum+= point[point.length - 1];
		}
		
		System.out.println(sum);
	}
} 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 scan = new Scanner(System.in);
		int n = scan.nextInt();
		Integer[] point = new Integer[n];
		for (int i = 0; i < n; i++) {
			point[i] = scan.nextInt();
		}
		
		Arrays.sort(point, Collections.reverseOrder());
		
		int sum = 0;
		for (int i = 0; i + 1 < point.length; i += 2) {
			sum += point[i] - point[i + 1];
		}
		if (point.length % 2 == 1) {
			sum+= point[point.length - 1];
		}
		
		System.out.println(sum);
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Integer[] point = new Integer[n];
		for (int i = 0; i < n; i++) {
			point[i] = scan.nextInt();
		}
		
		Arrays.sort(point, Collections.reverseOrder());
		
		int sum = 0;
		for (int i = 0; i + 1 < point.length; i += 2) {
			sum += point[i] - point[i + 1];
		}
		if (point.length % 2 == 1) {
			sum+= point[point.length - 1];
		}
		
		System.out.println(sum);
	} main {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Integer[] point = new Integer[n];
		for (int i = 0; i < n; i++) {
			point[i] = scan.nextInt();
		}
		
		Arrays.sort(point, Collections.reverseOrder());
		
		int sum = 0;
		for (int i = 0; i + 1 < point.length; i += 2) {
			sum += point[i] - point[i + 1];
		}
		if (point.length % 2 == 1) {
			sum+= point[point.length - 1];
		}
		
		System.out.println(sum);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan Integer[] point = new Integer[n]; point new Integer[n] n for (int i = 0; i < n; i++) {
			point[i] = scan.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			point[i] = scan.nextInt();
		} {
			point[i] = scan.nextInt();
		} point[i] = scan.nextInt() point[i] point i scan.nextInt() scan.nextInt scan Arrays.sort(point, Collections.reverseOrder()) Arrays.sort Arrays point Collections.reverseOrder() Collections.reverseOrder Collections int sum = 0; sum 0 for (int i = 0; i + 1 < point.length; i += 2) {
			sum += point[i] - point[i + 1];
		} int i = 0; int i = 0; i 0 i + 1 < point.length i + 1 i 1 point.length point point.length i += 2 i += 2 i 2 {
			sum += point[i] - point[i + 1];
		} {
			sum += point[i] - point[i + 1];
		} sum += point[i] - point[i + 1] sum point[i] - point[i + 1] point[i] point i point[i + 1] point i + 1 i 1 if (point.length % 2 == 1) {
			sum+= point[point.length - 1];
		} point.length % 2 == 1 point.length % 2 point.length point point.length 2 1 {
			sum+= point[point.length - 1];
		} sum+= point[point.length - 1] sum point[point.length - 1] point point.length - 1 point.length point point.length 1 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Integer[] point = new Integer[n];
		for (int i = 0; i < n; i++) {
			point[i] = scan.nextInt();
		}
		
		Arrays.sort(point, Collections.reverseOrder());
		
		int sum = 0;
		for (int i = 0; i + 1 < point.length; i += 2) {
			sum += point[i] - point[i + 1];
		}
		if (point.length % 2 == 1) {
			sum+= point[point.length - 1];
		}
		
		System.out.println(sum);
	}
} public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Integer[] point = new Integer[n];
		for (int i = 0; i < n; i++) {
			point[i] = scan.nextInt();
		}
		
		Arrays.sort(point, Collections.reverseOrder());
		
		int sum = 0;
		for (int i = 0; i + 1 < point.length; i += 2) {
			sum += point[i] - point[i + 1];
		}
		if (point.length % 2 == 1) {
			sum+= point[point.length - 1];
		}
		
		System.out.println(sum);
	}
} Main

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

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Integer[] point = new Integer[n];
		for (int i = 0; i < n; i++) {
			point[i] = scan.nextInt();
		}
		
		Arrays.sort(point, Collections.reverseOrder());
		
		int sum = 0;
		for (int i = 0; i + 1 < point.length; i += 2) {
			sum += point[i] - point[i + 1];
		}
		if (point.length % 2 == 1) {
			sum+= point[point.length - 1];
		}
		
		System.out.println(sum);
	}
}
