import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		int[] a = new int[t];
		int j = 0;
		while (t-- > 0) {
			a[j] = sc.nextInt();
			j++;
		}
		sc.close();
		Arrays.sort(a);
		int len = a.length;
		int A = 0; //for Alice
		int B = 0; //for Bob

		for (int i = 0; i<len; i+=2) {
			A+=a[i];
		}
		for (int i = 1; i<len; i+=2) {
			B+=a[i];
		}

		int result = Math.abs(A-B);
		System.out.println(result);
	}
} import java.util.*; util.* java import java.io.*; io.* java import java.lang.*; lang.* java public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		int[] a = new int[t];
		int j = 0;
		while (t-- > 0) {
			a[j] = sc.nextInt();
			j++;
		}
		sc.close();
		Arrays.sort(a);
		int len = a.length;
		int A = 0; //for Alice
		int B = 0; //for Bob

		for (int i = 0; i<len; i+=2) {
			A+=a[i];
		}
		for (int i = 1; i<len; i+=2) {
			B+=a[i];
		}

		int result = Math.abs(A-B);
		System.out.println(result);
	}
} Main public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		int[] a = new int[t];
		int j = 0;
		while (t-- > 0) {
			a[j] = sc.nextInt();
			j++;
		}
		sc.close();
		Arrays.sort(a);
		int len = a.length;
		int A = 0; //for Alice
		int B = 0; //for Bob

		for (int i = 0; i<len; i+=2) {
			A+=a[i];
		}
		for (int i = 1; i<len; i+=2) {
			B+=a[i];
		}

		int result = Math.abs(A-B);
		System.out.println(result);
	} main {
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		int[] a = new int[t];
		int j = 0;
		while (t-- > 0) {
			a[j] = sc.nextInt();
			j++;
		}
		sc.close();
		Arrays.sort(a);
		int len = a.length;
		int A = 0; //for Alice
		int B = 0; //for Bob

		for (int i = 0; i<len; i+=2) {
			A+=a[i];
		}
		for (int i = 1; i<len; i+=2) {
			B+=a[i];
		}

		int result = Math.abs(A-B);
		System.out.println(result);
	} Scanner sc = new Scanner (System.in); sc new Scanner (System.in) int t = sc.nextInt(); t sc.nextInt() sc.nextInt sc int[] a = new int[t]; a new int[t] t int j = 0; j 0 while (t-- > 0) {
			a[j] = sc.nextInt();
			j++;
		} t-- > 0 t-- t 0 {
			a[j] = sc.nextInt();
			j++;
		} a[j] = sc.nextInt() a[j] a j sc.nextInt() sc.nextInt sc j++ j sc.close() sc.close sc Arrays.sort(a) Arrays.sort Arrays a int len = a.length; len a.length a a.length int A = 0; A 0 int B = 0; B 0 for (int i = 0; i<len; i+=2) {
			A+=a[i];
		} int i = 0; int i = 0; i 0 i<len i len i+=2 i+=2 i 2 {
			A+=a[i];
		} {
			A+=a[i];
		} A+=a[i] A a[i] a i for (int i = 1; i<len; i+=2) {
			B+=a[i];
		} int i = 1; int i = 1; i 1 i<len i len i+=2 i+=2 i 2 {
			B+=a[i];
		} {
			B+=a[i];
		} B+=a[i] B a[i] a i int result = Math.abs(A-B); result Math.abs(A-B) Math.abs Math A-B A B 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);
		int t = sc.nextInt();
		int[] a = new int[t];
		int j = 0;
		while (t-- > 0) {
			a[j] = sc.nextInt();
			j++;
		}
		sc.close();
		Arrays.sort(a);
		int len = a.length;
		int A = 0; //for Alice
		int B = 0; //for Bob

		for (int i = 0; i<len; i+=2) {
			A+=a[i];
		}
		for (int i = 1; i<len; i+=2) {
			B+=a[i];
		}

		int result = Math.abs(A-B);
		System.out.println(result);
	}
} public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		int[] a = new int[t];
		int j = 0;
		while (t-- > 0) {
			a[j] = sc.nextInt();
			j++;
		}
		sc.close();
		Arrays.sort(a);
		int len = a.length;
		int A = 0; //for Alice
		int B = 0; //for Bob

		for (int i = 0; i<len; i+=2) {
			A+=a[i];
		}
		for (int i = 1; i<len; i+=2) {
			B+=a[i];
		}

		int result = Math.abs(A-B);
		System.out.println(result);
	}
} Main
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		int[] a = new int[t];
		int j = 0;
		while (t-- > 0) {
			a[j] = sc.nextInt();
			j++;
		}
		sc.close();
		Arrays.sort(a);
		int len = a.length;
		int A = 0; //for Alice
		int B = 0; //for Bob

		for (int i = 0; i<len; i+=2) {
			A+=a[i];
		}
		for (int i = 1; i<len; i+=2) {
			B+=a[i];
		}

		int result = Math.abs(A-B);
		System.out.println(result);
	}
}
