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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			a.add(sc.nextInt());
		}
		Collections.sort(a, Collections.reverseOrder());

		int aliceScore = 0;
		int bobScore = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) {
				aliceScore += a.get(i);
			} else {
				bobScore += a.get(i);
			}
		}

		System.out.println(aliceScore-bobScore);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List 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 N = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			a.add(sc.nextInt());
		}
		Collections.sort(a, Collections.reverseOrder());

		int aliceScore = 0;
		int bobScore = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) {
				aliceScore += a.get(i);
			} else {
				bobScore += a.get(i);
			}
		}

		System.out.println(aliceScore-bobScore);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			a.add(sc.nextInt());
		}
		Collections.sort(a, Collections.reverseOrder());

		int aliceScore = 0;
		int bobScore = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) {
				aliceScore += a.get(i);
			} else {
				bobScore += a.get(i);
			}
		}

		System.out.println(aliceScore-bobScore);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			a.add(sc.nextInt());
		}
		Collections.sort(a, Collections.reverseOrder());

		int aliceScore = 0;
		int bobScore = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) {
				aliceScore += a.get(i);
			} else {
				bobScore += a.get(i);
			}
		}

		System.out.println(aliceScore-bobScore);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc List<Integer> a = new ArrayList<>(); a new ArrayList<>() for(int i = 0; i < N; i++) {
			a.add(sc.nextInt());
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			a.add(sc.nextInt());
		} {
			a.add(sc.nextInt());
		} a.add(sc.nextInt()) a.add a sc.nextInt() sc.nextInt sc Collections.sort(a, Collections.reverseOrder()) Collections.sort Collections a Collections.reverseOrder() Collections.reverseOrder Collections int aliceScore = 0; aliceScore 0 int bobScore = 0; bobScore 0 for(int i = 0; i < N; i++) {
			if(i%2 == 0) {
				aliceScore += a.get(i);
			} else {
				bobScore += a.get(i);
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if(i%2 == 0) {
				aliceScore += a.get(i);
			} else {
				bobScore += a.get(i);
			}
		} {
			if(i%2 == 0) {
				aliceScore += a.get(i);
			} else {
				bobScore += a.get(i);
			}
		} if(i%2 == 0) {
				aliceScore += a.get(i);
			} else {
				bobScore += a.get(i);
			} i%2 == 0 i%2 i 2 0 {
				aliceScore += a.get(i);
			} aliceScore += a.get(i) aliceScore a.get(i) a.get a i {
				bobScore += a.get(i);
			} bobScore += a.get(i) bobScore a.get(i) a.get a i System.out.println(aliceScore-bobScore) System.out.println System.out System System.out aliceScore-bobScore aliceScore bobScore String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			a.add(sc.nextInt());
		}
		Collections.sort(a, Collections.reverseOrder());

		int aliceScore = 0;
		int bobScore = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) {
				aliceScore += a.get(i);
			} else {
				bobScore += a.get(i);
			}
		}

		System.out.println(aliceScore-bobScore);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			a.add(sc.nextInt());
		}
		Collections.sort(a, Collections.reverseOrder());

		int aliceScore = 0;
		int bobScore = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) {
				aliceScore += a.get(i);
			} else {
				bobScore += a.get(i);
			}
		}

		System.out.println(aliceScore-bobScore);
	}
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			a.add(sc.nextInt());
		}
		Collections.sort(a, Collections.reverseOrder());

		int aliceScore = 0;
		int bobScore = 0;
		for(int i = 0; i < N; i++) {
			if(i%2 == 0) {
				aliceScore += a.get(i);
			} else {
				bobScore += a.get(i);
			}
		}

		System.out.println(aliceScore-bobScore);
	}
}