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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		scan.close();
		Arrays.sort(a);
		int alice=0,bob=0,check=0;
		for(int i=n-1;i>=0;i--) {
			if(check%2==0)alice+=a[i];
			else bob+=a[i];
			check++;
		}
		System.out.println(alice-bob);
	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		scan.close();
		Arrays.sort(a);
		int alice=0,bob=0,check=0;
		for(int i=n-1;i>=0;i--) {
			if(check%2==0)alice+=a[i];
			else bob+=a[i];
			check++;
		}
		System.out.println(alice-bob);
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		scan.close();
		Arrays.sort(a);
		int alice=0,bob=0,check=0;
		for(int i=n-1;i>=0;i--) {
			if(check%2==0)alice+=a[i];
			else bob+=a[i];
			check++;
		}
		System.out.println(alice-bob);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		scan.close();
		Arrays.sort(a);
		int alice=0,bob=0,check=0;
		for(int i=n-1;i>=0;i--) {
			if(check%2==0)alice+=a[i];
			else bob+=a[i];
			check++;
		}
		System.out.println(alice-bob);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int a[]=new int[n]; a new int[n] n for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			a[i]=scan.nextInt();
		} {
			a[i]=scan.nextInt();
		} a[i]=scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan scan.close() scan.close scan Arrays.sort(a) Arrays.sort Arrays a int alice=0 alice 0 bob=0 bob 0 check=0; check 0 for(int i=n-1;i>=0;i--) {
			if(check%2==0)alice+=a[i];
			else bob+=a[i];
			check++;
		} int i=n-1; int i=n-1; i n-1 n 1 i>=0 i 0 i-- i-- i {
			if(check%2==0)alice+=a[i];
			else bob+=a[i];
			check++;
		} {
			if(check%2==0)alice+=a[i];
			else bob+=a[i];
			check++;
		} if(check%2==0)alice+=a[i];
			else bob+=a[i]; check%2==0 check%2 check 2 0 alice+=a[i] alice a[i] a i bob+=a[i] bob a[i] a i check++ check 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 scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		scan.close();
		Arrays.sort(a);
		int alice=0,bob=0,check=0;
		for(int i=n-1;i>=0;i--) {
			if(check%2==0)alice+=a[i];
			else bob+=a[i];
			check++;
		}
		System.out.println(alice-bob);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		scan.close();
		Arrays.sort(a);
		int alice=0,bob=0,check=0;
		for(int i=n-1;i>=0;i--) {
			if(check%2==0)alice+=a[i];
			else bob+=a[i];
			check++;
		}
		System.out.println(alice-bob);
	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		scan.close();
		Arrays.sort(a);
		int alice=0,bob=0,check=0;
		for(int i=n-1;i>=0;i--) {
			if(check%2==0)alice+=a[i];
			else bob+=a[i];
			check++;
		}
		System.out.println(alice-bob);
	}

}