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

public class Main {
	public static void main(String[] args) {
		// 処理対象個数の入力
		Scanner sc = new Scanner(System.in);
		int inputDeckNum = sc.nextInt();
		ArrayList<Integer> deckList = new ArrayList<>();
		for(int i=1;i <= inputDeckNum;i++) {
			deckList.add(sc.nextInt());
		}

		Collections.sort(deckList, Collections.reverseOrder());

		int first_player = 0;
		int second_player = 0;

		for(int i = 0;i < deckList.size();i++) {
			if(i % 2 == 0) {
				first_player += deckList.get(i);
			}else{
				second_player += deckList.get(i);
			}
		}

		sc.close();

		// 出力
		System.out.println(first_player - second_player);

	}

} import java.util.ArrayList; ArrayList 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 sc = new Scanner(System.in);
		int inputDeckNum = sc.nextInt();
		ArrayList<Integer> deckList = new ArrayList<>();
		for(int i=1;i <= inputDeckNum;i++) {
			deckList.add(sc.nextInt());
		}

		Collections.sort(deckList, Collections.reverseOrder());

		int first_player = 0;
		int second_player = 0;

		for(int i = 0;i < deckList.size();i++) {
			if(i % 2 == 0) {
				first_player += deckList.get(i);
			}else{
				second_player += deckList.get(i);
			}
		}

		sc.close();

		// 出力
		System.out.println(first_player - second_player);

	}

} Main public static void main(String[] args) {
		// 処理対象個数の入力
		Scanner sc = new Scanner(System.in);
		int inputDeckNum = sc.nextInt();
		ArrayList<Integer> deckList = new ArrayList<>();
		for(int i=1;i <= inputDeckNum;i++) {
			deckList.add(sc.nextInt());
		}

		Collections.sort(deckList, Collections.reverseOrder());

		int first_player = 0;
		int second_player = 0;

		for(int i = 0;i < deckList.size();i++) {
			if(i % 2 == 0) {
				first_player += deckList.get(i);
			}else{
				second_player += deckList.get(i);
			}
		}

		sc.close();

		// 出力
		System.out.println(first_player - second_player);

	} main {
		// 処理対象個数の入力
		Scanner sc = new Scanner(System.in);
		int inputDeckNum = sc.nextInt();
		ArrayList<Integer> deckList = new ArrayList<>();
		for(int i=1;i <= inputDeckNum;i++) {
			deckList.add(sc.nextInt());
		}

		Collections.sort(deckList, Collections.reverseOrder());

		int first_player = 0;
		int second_player = 0;

		for(int i = 0;i < deckList.size();i++) {
			if(i % 2 == 0) {
				first_player += deckList.get(i);
			}else{
				second_player += deckList.get(i);
			}
		}

		sc.close();

		// 出力
		System.out.println(first_player - second_player);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int inputDeckNum = sc.nextInt(); inputDeckNum sc.nextInt() sc.nextInt sc ArrayList<Integer> deckList = new ArrayList<>(); deckList new ArrayList<>() for(int i=1;i <= inputDeckNum;i++) {
			deckList.add(sc.nextInt());
		} int i=1; int i=1; i 1 i <= inputDeckNum i inputDeckNum i++ i++ i {
			deckList.add(sc.nextInt());
		} {
			deckList.add(sc.nextInt());
		} deckList.add(sc.nextInt()) deckList.add deckList sc.nextInt() sc.nextInt sc Collections.sort(deckList, Collections.reverseOrder()) Collections.sort Collections deckList Collections.reverseOrder() Collections.reverseOrder Collections int first_player = 0; first_player 0 int second_player = 0; second_player 0 for(int i = 0;i < deckList.size();i++) {
			if(i % 2 == 0) {
				first_player += deckList.get(i);
			}else{
				second_player += deckList.get(i);
			}
		} int i = 0; int i = 0; i 0 i < deckList.size() i deckList.size() deckList.size deckList i++ i++ i {
			if(i % 2 == 0) {
				first_player += deckList.get(i);
			}else{
				second_player += deckList.get(i);
			}
		} {
			if(i % 2 == 0) {
				first_player += deckList.get(i);
			}else{
				second_player += deckList.get(i);
			}
		} if(i % 2 == 0) {
				first_player += deckList.get(i);
			}else{
				second_player += deckList.get(i);
			} i % 2 == 0 i % 2 i 2 0 {
				first_player += deckList.get(i);
			} first_player += deckList.get(i) first_player deckList.get(i) deckList.get deckList i {
				second_player += deckList.get(i);
			} second_player += deckList.get(i) second_player deckList.get(i) deckList.get deckList i sc.close() sc.close sc System.out.println(first_player - second_player) System.out.println System.out System System.out first_player - second_player first_player second_player String[] args args public class Main {
	public static void main(String[] args) {
		// 処理対象個数の入力
		Scanner sc = new Scanner(System.in);
		int inputDeckNum = sc.nextInt();
		ArrayList<Integer> deckList = new ArrayList<>();
		for(int i=1;i <= inputDeckNum;i++) {
			deckList.add(sc.nextInt());
		}

		Collections.sort(deckList, Collections.reverseOrder());

		int first_player = 0;
		int second_player = 0;

		for(int i = 0;i < deckList.size();i++) {
			if(i % 2 == 0) {
				first_player += deckList.get(i);
			}else{
				second_player += deckList.get(i);
			}
		}

		sc.close();

		// 出力
		System.out.println(first_player - second_player);

	}

} public class Main {
	public static void main(String[] args) {
		// 処理対象個数の入力
		Scanner sc = new Scanner(System.in);
		int inputDeckNum = sc.nextInt();
		ArrayList<Integer> deckList = new ArrayList<>();
		for(int i=1;i <= inputDeckNum;i++) {
			deckList.add(sc.nextInt());
		}

		Collections.sort(deckList, Collections.reverseOrder());

		int first_player = 0;
		int second_player = 0;

		for(int i = 0;i < deckList.size();i++) {
			if(i % 2 == 0) {
				first_player += deckList.get(i);
			}else{
				second_player += deckList.get(i);
			}
		}

		sc.close();

		// 出力
		System.out.println(first_player - second_player);

	}

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

public class Main {
	public static void main(String[] args) {
		// 処理対象個数の入力
		Scanner sc = new Scanner(System.in);
		int inputDeckNum = sc.nextInt();
		ArrayList<Integer> deckList = new ArrayList<>();
		for(int i=1;i <= inputDeckNum;i++) {
			deckList.add(sc.nextInt());
		}

		Collections.sort(deckList, Collections.reverseOrder());

		int first_player = 0;
		int second_player = 0;

		for(int i = 0;i < deckList.size();i++) {
			if(i % 2 == 0) {
				first_player += deckList.get(i);
			}else{
				second_player += deckList.get(i);
			}
		}

		sc.close();

		// 出力
		System.out.println(first_player - second_player);

	}

}