import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//要素数受け取り
		int n = sc.nextInt();
		int sum = 0;
		Integer [] list = new Integer[n];
		for(int i = 0; i < n; i ++){
			list[i] = sc.nextInt();
		}
		Arrays.sort(list,Collections.reverseOrder());
		if(n%2 == 0){
			for(int t = 0; t < n-1; t += 2){
				sum += list[t] - list[t+1];
				}
			}else{
				for(int t = 0; t < n-2; t += 2){
					sum += list[t] - list[t+1];
				}
				sum += list[n-1];
			}
			System.out.println(sum);
		}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//要素数受け取り
		int n = sc.nextInt();
		int sum = 0;
		Integer [] list = new Integer[n];
		for(int i = 0; i < n; i ++){
			list[i] = sc.nextInt();
		}
		Arrays.sort(list,Collections.reverseOrder());
		if(n%2 == 0){
			for(int t = 0; t < n-1; t += 2){
				sum += list[t] - list[t+1];
				}
			}else{
				for(int t = 0; t < n-2; t += 2){
					sum += list[t] - list[t+1];
				}
				sum += list[n-1];
			}
			System.out.println(sum);
		}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//要素数受け取り
		int n = sc.nextInt();
		int sum = 0;
		Integer [] list = new Integer[n];
		for(int i = 0; i < n; i ++){
			list[i] = sc.nextInt();
		}
		Arrays.sort(list,Collections.reverseOrder());
		if(n%2 == 0){
			for(int t = 0; t < n-1; t += 2){
				sum += list[t] - list[t+1];
				}
			}else{
				for(int t = 0; t < n-2; t += 2){
					sum += list[t] - list[t+1];
				}
				sum += list[n-1];
			}
			System.out.println(sum);
		} main {
		Scanner sc = new Scanner(System.in);
		//要素数受け取り
		int n = sc.nextInt();
		int sum = 0;
		Integer [] list = new Integer[n];
		for(int i = 0; i < n; i ++){
			list[i] = sc.nextInt();
		}
		Arrays.sort(list,Collections.reverseOrder());
		if(n%2 == 0){
			for(int t = 0; t < n-1; t += 2){
				sum += list[t] - list[t+1];
				}
			}else{
				for(int t = 0; t < n-2; t += 2){
					sum += list[t] - list[t+1];
				}
				sum += list[n-1];
			}
			System.out.println(sum);
		} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int sum = 0; sum 0 Integer [] list = new Integer[n]; list new Integer[n] n for(int i = 0; i < n; i ++){
			list[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i ++ i ++ i {
			list[i] = sc.nextInt();
		} {
			list[i] = sc.nextInt();
		} list[i] = sc.nextInt() list[i] list i sc.nextInt() sc.nextInt sc Arrays.sort(list,Collections.reverseOrder()) Arrays.sort Arrays list Collections.reverseOrder() Collections.reverseOrder Collections if(n%2 == 0){
			for(int t = 0; t < n-1; t += 2){
				sum += list[t] - list[t+1];
				}
			}else{
				for(int t = 0; t < n-2; t += 2){
					sum += list[t] - list[t+1];
				}
				sum += list[n-1];
			} n%2 == 0 n%2 n 2 0 {
			for(int t = 0; t < n-1; t += 2){
				sum += list[t] - list[t+1];
				}
			} for(int t = 0; t < n-1; t += 2){
				sum += list[t] - list[t+1];
				} int t = 0; int t = 0; t 0 t < n-1 t n-1 n 1 t += 2 t += 2 t 2 {
				sum += list[t] - list[t+1];
				} {
				sum += list[t] - list[t+1];
				} sum += list[t] - list[t+1] sum list[t] - list[t+1] list[t] list t list[t+1] list t+1 t 1 {
				for(int t = 0; t < n-2; t += 2){
					sum += list[t] - list[t+1];
				}
				sum += list[n-1];
			} for(int t = 0; t < n-2; t += 2){
					sum += list[t] - list[t+1];
				} int t = 0; int t = 0; t 0 t < n-2 t n-2 n 2 t += 2 t += 2 t 2 {
					sum += list[t] - list[t+1];
				} {
					sum += list[t] - list[t+1];
				} sum += list[t] - list[t+1] sum list[t] - list[t+1] list[t] list t list[t+1] list t+1 t 1 sum += list[n-1] sum list[n-1] list n-1 n 1 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//要素数受け取り
		int n = sc.nextInt();
		int sum = 0;
		Integer [] list = new Integer[n];
		for(int i = 0; i < n; i ++){
			list[i] = sc.nextInt();
		}
		Arrays.sort(list,Collections.reverseOrder());
		if(n%2 == 0){
			for(int t = 0; t < n-1; t += 2){
				sum += list[t] - list[t+1];
				}
			}else{
				for(int t = 0; t < n-2; t += 2){
					sum += list[t] - list[t+1];
				}
				sum += list[n-1];
			}
			System.out.println(sum);
		}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//要素数受け取り
		int n = sc.nextInt();
		int sum = 0;
		Integer [] list = new Integer[n];
		for(int i = 0; i < n; i ++){
			list[i] = sc.nextInt();
		}
		Arrays.sort(list,Collections.reverseOrder());
		if(n%2 == 0){
			for(int t = 0; t < n-1; t += 2){
				sum += list[t] - list[t+1];
				}
			}else{
				for(int t = 0; t < n-2; t += 2){
					sum += list[t] - list[t+1];
				}
				sum += list[n-1];
			}
			System.out.println(sum);
		}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//要素数受け取り
		int n = sc.nextInt();
		int sum = 0;
		Integer [] list = new Integer[n];
		for(int i = 0; i < n; i ++){
			list[i] = sc.nextInt();
		}
		Arrays.sort(list,Collections.reverseOrder());
		if(n%2 == 0){
			for(int t = 0; t < n-1; t += 2){
				sum += list[t] - list[t+1];
				}
			}else{
				for(int t = 0; t < n-2; t += 2){
					sum += list[t] - list[t+1];
				}
				sum += list[n-1];
			}
			System.out.println(sum);
		}
}
