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

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 
		 int N = scan.nextInt();
		 Integer a[] = new Integer[N];
		 
		 for (int i = 0; i < N; i++) {
			 a[i] = scan.nextInt();
		 }
		 
		 Arrays.sort(a, Collections.reverseOrder());
		 
		 int sum_Allice = 0;
		 int sum_Bob = 0;
		 
		 for (int i = 0; i < N; i++) {
			 if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 }
		 }
		 
		 System.out.println(sum_Allice - sum_Bob);
		 scan.close();
		 

	}

} import java.util.Arrays; Arrays 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 scan = new Scanner(System.in);
		 
		 int N = scan.nextInt();
		 Integer a[] = new Integer[N];
		 
		 for (int i = 0; i < N; i++) {
			 a[i] = scan.nextInt();
		 }
		 
		 Arrays.sort(a, Collections.reverseOrder());
		 
		 int sum_Allice = 0;
		 int sum_Bob = 0;
		 
		 for (int i = 0; i < N; i++) {
			 if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 }
		 }
		 
		 System.out.println(sum_Allice - sum_Bob);
		 scan.close();
		 

	}

} Main public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 
		 int N = scan.nextInt();
		 Integer a[] = new Integer[N];
		 
		 for (int i = 0; i < N; i++) {
			 a[i] = scan.nextInt();
		 }
		 
		 Arrays.sort(a, Collections.reverseOrder());
		 
		 int sum_Allice = 0;
		 int sum_Bob = 0;
		 
		 for (int i = 0; i < N; i++) {
			 if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 }
		 }
		 
		 System.out.println(sum_Allice - sum_Bob);
		 scan.close();
		 

	} main {
		 Scanner scan = new Scanner(System.in);
		 
		 int N = scan.nextInt();
		 Integer a[] = new Integer[N];
		 
		 for (int i = 0; i < N; i++) {
			 a[i] = scan.nextInt();
		 }
		 
		 Arrays.sort(a, Collections.reverseOrder());
		 
		 int sum_Allice = 0;
		 int sum_Bob = 0;
		 
		 for (int i = 0; i < N; i++) {
			 if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 }
		 }
		 
		 System.out.println(sum_Allice - sum_Bob);
		 scan.close();
		 

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan Integer a[] = new Integer[N]; a new Integer[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 Arrays.sort(a, Collections.reverseOrder()) Arrays.sort Arrays a Collections.reverseOrder() Collections.reverseOrder Collections int sum_Allice = 0; sum_Allice 0 int sum_Bob = 0; sum_Bob 0 for (int i = 0; i < N; i++) {
			 if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 }
		 } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			 if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 }
		 } {
			 if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 }
		 } if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 } i % 2 == 0 i % 2 i 2 0 {
				 sum_Allice += a[i];
			 } sum_Allice += a[i] sum_Allice a[i] a i {
				 sum_Bob += a[i];
			 } sum_Bob += a[i] sum_Bob a[i] a i System.out.println(sum_Allice - sum_Bob) System.out.println System.out System System.out sum_Allice - sum_Bob sum_Allice sum_Bob scan.close() scan.close scan String[] args args public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 
		 int N = scan.nextInt();
		 Integer a[] = new Integer[N];
		 
		 for (int i = 0; i < N; i++) {
			 a[i] = scan.nextInt();
		 }
		 
		 Arrays.sort(a, Collections.reverseOrder());
		 
		 int sum_Allice = 0;
		 int sum_Bob = 0;
		 
		 for (int i = 0; i < N; i++) {
			 if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 }
		 }
		 
		 System.out.println(sum_Allice - sum_Bob);
		 scan.close();
		 

	}

} public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 
		 int N = scan.nextInt();
		 Integer a[] = new Integer[N];
		 
		 for (int i = 0; i < N; i++) {
			 a[i] = scan.nextInt();
		 }
		 
		 Arrays.sort(a, Collections.reverseOrder());
		 
		 int sum_Allice = 0;
		 int sum_Bob = 0;
		 
		 for (int i = 0; i < N; i++) {
			 if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 }
		 }
		 
		 System.out.println(sum_Allice - sum_Bob);
		 scan.close();
		 

	}

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

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 
		 int N = scan.nextInt();
		 Integer a[] = new Integer[N];
		 
		 for (int i = 0; i < N; i++) {
			 a[i] = scan.nextInt();
		 }
		 
		 Arrays.sort(a, Collections.reverseOrder());
		 
		 int sum_Allice = 0;
		 int sum_Bob = 0;
		 
		 for (int i = 0; i < N; i++) {
			 if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 }
		 }
		 
		 System.out.println(sum_Allice - sum_Bob);
		 scan.close();
		 

	}

}
