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

// https://atcoder.jp/contests/abc088/tasks/abc088_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		Integer[] numbers = new Integer[n];
		for(int i=0;i<n;i++) {
			numbers[i] = scanner .nextInt();
		}

		scanner.close();

		// 配列をソート（降順）
		Arrays.sort(numbers,Collections.reverseOrder());

		int sum1 = 0;
		int sum2 = 0;
		for(int i=0;i<n;i++) {
			if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			}
		}
		System.out.println(sum1-sum2);
	}

} 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) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		Integer[] numbers = new Integer[n];
		for(int i=0;i<n;i++) {
			numbers[i] = scanner .nextInt();
		}

		scanner.close();

		// 配列をソート（降順）
		Arrays.sort(numbers,Collections.reverseOrder());

		int sum1 = 0;
		int sum2 = 0;
		for(int i=0;i<n;i++) {
			if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			}
		}
		System.out.println(sum1-sum2);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		Integer[] numbers = new Integer[n];
		for(int i=0;i<n;i++) {
			numbers[i] = scanner .nextInt();
		}

		scanner.close();

		// 配列をソート（降順）
		Arrays.sort(numbers,Collections.reverseOrder());

		int sum1 = 0;
		int sum2 = 0;
		for(int i=0;i<n;i++) {
			if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			}
		}
		System.out.println(sum1-sum2);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		Integer[] numbers = new Integer[n];
		for(int i=0;i<n;i++) {
			numbers[i] = scanner .nextInt();
		}

		scanner.close();

		// 配列をソート（降順）
		Arrays.sort(numbers,Collections.reverseOrder());

		int sum1 = 0;
		int sum2 = 0;
		for(int i=0;i<n;i++) {
			if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			}
		}
		System.out.println(sum1-sum2);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner Integer[] numbers = new Integer[n]; numbers new Integer[n] n for(int i=0;i<n;i++) {
			numbers[i] = scanner .nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			numbers[i] = scanner .nextInt();
		} {
			numbers[i] = scanner .nextInt();
		} numbers[i] = scanner .nextInt() numbers[i] numbers i scanner .nextInt() scanner .nextInt scanner scanner.close() scanner.close scanner Arrays.sort(numbers,Collections.reverseOrder()) Arrays.sort Arrays numbers Collections.reverseOrder() Collections.reverseOrder Collections int sum1 = 0; sum1 0 int sum2 = 0; sum2 0 for(int i=0;i<n;i++) {
			if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			}
		} {
			if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			}
		} if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			} i%2==0 i%2 i 2 0 {
				sum1 = sum1 + numbers[i];
			} sum1 = sum1 + numbers[i] sum1 sum1 + numbers[i] sum1 numbers[i] numbers i {
				sum2 = sum2 + numbers[i];
			} sum2 = sum2 + numbers[i] sum2 sum2 + numbers[i] sum2 numbers[i] numbers i System.out.println(sum1-sum2) System.out.println System.out System System.out sum1-sum2 sum1 sum2 String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		Integer[] numbers = new Integer[n];
		for(int i=0;i<n;i++) {
			numbers[i] = scanner .nextInt();
		}

		scanner.close();

		// 配列をソート（降順）
		Arrays.sort(numbers,Collections.reverseOrder());

		int sum1 = 0;
		int sum2 = 0;
		for(int i=0;i<n;i++) {
			if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			}
		}
		System.out.println(sum1-sum2);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		Integer[] numbers = new Integer[n];
		for(int i=0;i<n;i++) {
			numbers[i] = scanner .nextInt();
		}

		scanner.close();

		// 配列をソート（降順）
		Arrays.sort(numbers,Collections.reverseOrder());

		int sum1 = 0;
		int sum2 = 0;
		for(int i=0;i<n;i++) {
			if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			}
		}
		System.out.println(sum1-sum2);
	}

} Main

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

// https://atcoder.jp/contests/abc088/tasks/abc088_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		Integer[] numbers = new Integer[n];
		for(int i=0;i<n;i++) {
			numbers[i] = scanner .nextInt();
		}

		scanner.close();

		// 配列をソート（降順）
		Arrays.sort(numbers,Collections.reverseOrder());

		int sum1 = 0;
		int sum2 = 0;
		for(int i=0;i<n;i++) {
			if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			}
		}
		System.out.println(sum1-sum2);
	}

}