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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int Alice = 0;
		int Bob = 0;
		int n = sc.nextInt();
		int []a = new int [n ];
		
		for (int i = 0; i < n  ; i++) {
			a[i] = sc.nextInt();	
		}
		 Arrays.sort(a);
		 if (n % 2 == 0)
		for(int i = 1 ; i <= n/2 ; i++) {
			Alice += a[n - ( 2 * i - 1)];
			Bob += a[n - (2 * i) ];					
		}
		 if (n % 2 == 1) {
		for(int i = 1; i <= (n - 1)/2; i++) {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		}
		    Alice += a[0];
		 }
		 
		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) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int Alice = 0;
		int Bob = 0;
		int n = sc.nextInt();
		int []a = new int [n ];
		
		for (int i = 0; i < n  ; i++) {
			a[i] = sc.nextInt();	
		}
		 Arrays.sort(a);
		 if (n % 2 == 0)
		for(int i = 1 ; i <= n/2 ; i++) {
			Alice += a[n - ( 2 * i - 1)];
			Bob += a[n - (2 * i) ];					
		}
		 if (n % 2 == 1) {
		for(int i = 1; i <= (n - 1)/2; i++) {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		}
		    Alice += a[0];
		 }
		 
		System.out.println((Alice - Bob));
		
	}
			
	} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int Alice = 0;
		int Bob = 0;
		int n = sc.nextInt();
		int []a = new int [n ];
		
		for (int i = 0; i < n  ; i++) {
			a[i] = sc.nextInt();	
		}
		 Arrays.sort(a);
		 if (n % 2 == 0)
		for(int i = 1 ; i <= n/2 ; i++) {
			Alice += a[n - ( 2 * i - 1)];
			Bob += a[n - (2 * i) ];					
		}
		 if (n % 2 == 1) {
		for(int i = 1; i <= (n - 1)/2; i++) {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		}
		    Alice += a[0];
		 }
		 
		System.out.println((Alice - Bob));
		
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int Alice = 0;
		int Bob = 0;
		int n = sc.nextInt();
		int []a = new int [n ];
		
		for (int i = 0; i < n  ; i++) {
			a[i] = sc.nextInt();	
		}
		 Arrays.sort(a);
		 if (n % 2 == 0)
		for(int i = 1 ; i <= n/2 ; i++) {
			Alice += a[n - ( 2 * i - 1)];
			Bob += a[n - (2 * i) ];					
		}
		 if (n % 2 == 1) {
		for(int i = 1; i <= (n - 1)/2; i++) {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		}
		    Alice += a[0];
		 }
		 
		System.out.println((Alice - Bob));
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int Alice = 0; Alice 0 int Bob = 0; Bob 0 int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int []a = new int [n ]; a new int [n ] n for (int i = 0; i < n  ; i++) {
			a[i] = sc.nextInt();	
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			a[i] = sc.nextInt();	
		} {
			a[i] = sc.nextInt();	
		} a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc Arrays.sort(a) Arrays.sort Arrays a if (n % 2 == 0)
		for(int i = 1 ; i <= n/2 ; i++) {
			Alice += a[n - ( 2 * i - 1)];
			Bob += a[n - (2 * i) ];					
		} n % 2 == 0 n % 2 n 2 0 for(int i = 1 ; i <= n/2 ; i++) {
			Alice += a[n - ( 2 * i - 1)];
			Bob += a[n - (2 * i) ];					
		} int i = 1 ; int i = 1 ; i 1 i <= n/2 i n/2 n 2 i++ i++ i {
			Alice += a[n - ( 2 * i - 1)];
			Bob += a[n - (2 * i) ];					
		} {
			Alice += a[n - ( 2 * i - 1)];
			Bob += a[n - (2 * i) ];					
		} Alice += a[n - ( 2 * i - 1)] Alice a[n - ( 2 * i - 1)] a n - ( 2 * i - 1) n ( 2 * i - 1) 2 * i 2 i 1 Bob += a[n - (2 * i) ] Bob a[n - (2 * i) ] a n - (2 * i) n (2 * i) 2 i if (n % 2 == 1) {
		for(int i = 1; i <= (n - 1)/2; i++) {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		}
		    Alice += a[0];
		 } n % 2 == 1 n % 2 n 2 1 {
		for(int i = 1; i <= (n - 1)/2; i++) {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		}
		    Alice += a[0];
		 } for(int i = 1; i <= (n - 1)/2; i++) {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		} int i = 1; int i = 1; i 1 i <= (n - 1)/2 i (n - 1)/2 (n - 1) n 1 2 i++ i++ i {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		} {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		} Alice += a[n - (2 * i - 1)] Alice a[n - (2 * i - 1)] a n - (2 * i - 1) n (2 * i - 1) 2 * i 2 i 1 Bob += a[n - (i * 2)] Bob a[n - (i * 2)] a n - (i * 2) n (i * 2) i 2 Alice += a[0] Alice a[0] a 0 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) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int Alice = 0;
		int Bob = 0;
		int n = sc.nextInt();
		int []a = new int [n ];
		
		for (int i = 0; i < n  ; i++) {
			a[i] = sc.nextInt();	
		}
		 Arrays.sort(a);
		 if (n % 2 == 0)
		for(int i = 1 ; i <= n/2 ; i++) {
			Alice += a[n - ( 2 * i - 1)];
			Bob += a[n - (2 * i) ];					
		}
		 if (n % 2 == 1) {
		for(int i = 1; i <= (n - 1)/2; i++) {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		}
		    Alice += a[0];
		 }
		 
		System.out.println((Alice - Bob));
		
	}
			
	} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int Alice = 0;
		int Bob = 0;
		int n = sc.nextInt();
		int []a = new int [n ];
		
		for (int i = 0; i < n  ; i++) {
			a[i] = sc.nextInt();	
		}
		 Arrays.sort(a);
		 if (n % 2 == 0)
		for(int i = 1 ; i <= n/2 ; i++) {
			Alice += a[n - ( 2 * i - 1)];
			Bob += a[n - (2 * i) ];					
		}
		 if (n % 2 == 1) {
		for(int i = 1; i <= (n - 1)/2; i++) {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		}
		    Alice += a[0];
		 }
		 
		System.out.println((Alice - Bob));
		
	}
			
	} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int Alice = 0;
		int Bob = 0;
		int n = sc.nextInt();
		int []a = new int [n ];
		
		for (int i = 0; i < n  ; i++) {
			a[i] = sc.nextInt();	
		}
		 Arrays.sort(a);
		 if (n % 2 == 0)
		for(int i = 1 ; i <= n/2 ; i++) {
			Alice += a[n - ( 2 * i - 1)];
			Bob += a[n - (2 * i) ];					
		}
		 if (n % 2 == 1) {
		for(int i = 1; i <= (n - 1)/2; i++) {
			Alice += a[n - (2 * i - 1)];
			Bob += a[n - (i * 2)];					
		}
		    Alice += a[0];
		 }
		 
		System.out.println((Alice - Bob));
		
	}
			
	}


