import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int n = sc.nextInt();// N

		ArrayList<Integer> numList = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			numList.add(sc.nextInt());
		}

		// ソート（降順）
		Collections.sort(numList, Collections.reverseOrder());

		// 奇数回ならAliceに加点。偶数回ならBobに加点
		int alice = 0;
		int bob = 0;

		for(int i = 0; i < n; i++){
			int point = numList.get(i);
			if(i%2 == 0){
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			}else{
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			}
		}

		// 出力
		System.out.println(alice - bob);
	}
}

 import java.util.*; util.* java import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		int n = sc.nextInt();// N

		ArrayList<Integer> numList = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			numList.add(sc.nextInt());
		}

		// ソート（降順）
		Collections.sort(numList, Collections.reverseOrder());

		// 奇数回ならAliceに加点。偶数回ならBobに加点
		int alice = 0;
		int bob = 0;

		for(int i = 0; i < n; i++){
			int point = numList.get(i);
			if(i%2 == 0){
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			}else{
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			}
		}

		// 出力
		System.out.println(alice - bob);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		int n = sc.nextInt();// N

		ArrayList<Integer> numList = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			numList.add(sc.nextInt());
		}

		// ソート（降順）
		Collections.sort(numList, Collections.reverseOrder());

		// 奇数回ならAliceに加点。偶数回ならBobに加点
		int alice = 0;
		int bob = 0;

		for(int i = 0; i < n; i++){
			int point = numList.get(i);
			if(i%2 == 0){
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			}else{
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			}
		}

		// 出力
		System.out.println(alice - bob);
	} main {
		Scanner sc = new Scanner(System.in);

		// 入力
		int n = sc.nextInt();// N

		ArrayList<Integer> numList = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			numList.add(sc.nextInt());
		}

		// ソート（降順）
		Collections.sort(numList, Collections.reverseOrder());

		// 奇数回ならAliceに加点。偶数回ならBobに加点
		int alice = 0;
		int bob = 0;

		for(int i = 0; i < n; i++){
			int point = numList.get(i);
			if(i%2 == 0){
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			}else{
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			}
		}

		// 出力
		System.out.println(alice - bob);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc ArrayList<Integer> numList = new ArrayList<Integer>(); numList new ArrayList<Integer>() for(int i = 0; i < n; i++){
			numList.add(sc.nextInt());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			numList.add(sc.nextInt());
		} {
			numList.add(sc.nextInt());
		} numList.add(sc.nextInt()) numList.add numList sc.nextInt() sc.nextInt sc Collections.sort(numList, Collections.reverseOrder()) Collections.sort Collections numList Collections.reverseOrder() Collections.reverseOrder Collections int alice = 0; alice 0 int bob = 0; bob 0 for(int i = 0; i < n; i++){
			int point = numList.get(i);
			if(i%2 == 0){
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			}else{
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int point = numList.get(i);
			if(i%2 == 0){
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			}else{
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			}
		} {
			int point = numList.get(i);
			if(i%2 == 0){
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			}else{
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			}
		} int point = numList.get(i); point numList.get(i) numList.get numList i if(i%2 == 0){
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			}else{
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			} i%2 == 0 i%2 i 2 0 {
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			} alice = alice + point alice alice + point alice point {
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			} bob = bob + point bob bob + point bob point System.out.println(alice - bob) System.out.println System.out System System.out alice - bob alice bob String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		int n = sc.nextInt();// N

		ArrayList<Integer> numList = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			numList.add(sc.nextInt());
		}

		// ソート（降順）
		Collections.sort(numList, Collections.reverseOrder());

		// 奇数回ならAliceに加点。偶数回ならBobに加点
		int alice = 0;
		int bob = 0;

		for(int i = 0; i < n; i++){
			int point = numList.get(i);
			if(i%2 == 0){
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			}else{
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			}
		}

		// 出力
		System.out.println(alice - bob);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		int n = sc.nextInt();// N

		ArrayList<Integer> numList = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			numList.add(sc.nextInt());
		}

		// ソート（降順）
		Collections.sort(numList, Collections.reverseOrder());

		// 奇数回ならAliceに加点。偶数回ならBobに加点
		int alice = 0;
		int bob = 0;

		for(int i = 0; i < n; i++){
			int point = numList.get(i);
			if(i%2 == 0){
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			}else{
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			}
		}

		// 出力
		System.out.println(alice - bob);
	}
} Main
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int n = sc.nextInt();// N

		ArrayList<Integer> numList = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			numList.add(sc.nextInt());
		}

		// ソート（降順）
		Collections.sort(numList, Collections.reverseOrder());

		// 奇数回ならAliceに加点。偶数回ならBobに加点
		int alice = 0;
		int bob = 0;

		for(int i = 0; i < n; i++){
			int point = numList.get(i);
			if(i%2 == 0){
				alice = alice + point; //奇数回 i = 0,2,4,・・・
				//System.out.println("aliceに" + point + "加算");
			}else{
				bob = bob + point; //偶数回 i = 1,3,5,・・・
				//System.out.println("bobに" + point + "加算");
			}
		}

		// 出力
		System.out.println(alice - bob);
	}
}


