import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int N = sc.nextInt();
		int result = 0;

		while (sc.hasNextInt()) {
			list.add(sc.nextInt());
		}
		Collections.sort(list, Collections.reverseOrder());
		
		int sign = 1;
		for (int tmp : list) {
			result += tmp * sign;
			sign *= -1;
		}
		
		System.out.println(result);
	}
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int N = sc.nextInt();
		int result = 0;

		while (sc.hasNextInt()) {
			list.add(sc.nextInt());
		}
		Collections.sort(list, Collections.reverseOrder());
		
		int sign = 1;
		for (int tmp : list) {
			result += tmp * sign;
			sign *= -1;
		}
		
		System.out.println(result);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int N = sc.nextInt();
		int result = 0;

		while (sc.hasNextInt()) {
			list.add(sc.nextInt());
		}
		Collections.sort(list, Collections.reverseOrder());
		
		int sign = 1;
		for (int tmp : list) {
			result += tmp * sign;
			sign *= -1;
		}
		
		System.out.println(result);
	} main {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int N = sc.nextInt();
		int result = 0;

		while (sc.hasNextInt()) {
			list.add(sc.nextInt());
		}
		Collections.sort(list, Collections.reverseOrder());
		
		int sign = 1;
		for (int tmp : list) {
			result += tmp * sign;
			sign *= -1;
		}
		
		System.out.println(result);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int result = 0; result 0 while (sc.hasNextInt()) {
			list.add(sc.nextInt());
		} sc.hasNextInt() sc.hasNextInt sc {
			list.add(sc.nextInt());
		} list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc Collections.sort(list, Collections.reverseOrder()) Collections.sort Collections list Collections.reverseOrder() Collections.reverseOrder Collections int sign = 1; sign 1 for (int tmp : list) {
			result += tmp * sign;
			sign *= -1;
		} int tmp list {
			result += tmp * sign;
			sign *= -1;
		} {
			result += tmp * sign;
			sign *= -1;
		} result += tmp * sign result tmp * sign tmp sign sign *= -1 sign -1 1 System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int N = sc.nextInt();
		int result = 0;

		while (sc.hasNextInt()) {
			list.add(sc.nextInt());
		}
		Collections.sort(list, Collections.reverseOrder());
		
		int sign = 1;
		for (int tmp : list) {
			result += tmp * sign;
			sign *= -1;
		}
		
		System.out.println(result);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int N = sc.nextInt();
		int result = 0;

		while (sc.hasNextInt()) {
			list.add(sc.nextInt());
		}
		Collections.sort(list, Collections.reverseOrder());
		
		int sign = 1;
		for (int tmp : list) {
			result += tmp * sign;
			sign *= -1;
		}
		
		System.out.println(result);
	}
} Main
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int N = sc.nextInt();
		int result = 0;

		while (sc.hasNextInt()) {
			list.add(sc.nextInt());
		}
		Collections.sort(list, Collections.reverseOrder());
		
		int sign = 1;
		for (int tmp : list) {
			result += tmp * sign;
			sign *= -1;
		}
		
		System.out.println(result);
	}
}
