import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int data[] = new int[N];
		for(int i = 0; i < N; i++) {
			data[i] = sc.nextInt();
		}
		Arrays.sort(data);
		int sum = 0;
		int n = 2;
		for(int i = N-1; i >= 0; i--) {
			if(n % 2 == 0) {
				sum = sum+data[i];
			}else {
				sum = sum-data[i];
			}
			n++;
		}
		System.out.println(sum);
		sc.close();
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int data[] = new int[N];
		for(int i = 0; i < N; i++) {
			data[i] = sc.nextInt();
		}
		Arrays.sort(data);
		int sum = 0;
		int n = 2;
		for(int i = N-1; i >= 0; i--) {
			if(n % 2 == 0) {
				sum = sum+data[i];
			}else {
				sum = sum-data[i];
			}
			n++;
		}
		System.out.println(sum);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int data[] = new int[N];
		for(int i = 0; i < N; i++) {
			data[i] = sc.nextInt();
		}
		Arrays.sort(data);
		int sum = 0;
		int n = 2;
		for(int i = N-1; i >= 0; i--) {
			if(n % 2 == 0) {
				sum = sum+data[i];
			}else {
				sum = sum-data[i];
			}
			n++;
		}
		System.out.println(sum);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int data[] = new int[N];
		for(int i = 0; i < N; i++) {
			data[i] = sc.nextInt();
		}
		Arrays.sort(data);
		int sum = 0;
		int n = 2;
		for(int i = N-1; i >= 0; i--) {
			if(n % 2 == 0) {
				sum = sum+data[i];
			}else {
				sum = sum-data[i];
			}
			n++;
		}
		System.out.println(sum);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int data[] = new int[N]; data new int[N] N for(int i = 0; i < N; i++) {
			data[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			data[i] = sc.nextInt();
		} {
			data[i] = sc.nextInt();
		} data[i] = sc.nextInt() data[i] data i sc.nextInt() sc.nextInt sc Arrays.sort(data) Arrays.sort Arrays data int sum = 0; sum 0 int n = 2; n 2 for(int i = N-1; i >= 0; i--) {
			if(n % 2 == 0) {
				sum = sum+data[i];
			}else {
				sum = sum-data[i];
			}
			n++;
		} int i = N-1; int i = N-1; i N-1 N 1 i >= 0 i 0 i-- i-- i {
			if(n % 2 == 0) {
				sum = sum+data[i];
			}else {
				sum = sum-data[i];
			}
			n++;
		} {
			if(n % 2 == 0) {
				sum = sum+data[i];
			}else {
				sum = sum-data[i];
			}
			n++;
		} if(n % 2 == 0) {
				sum = sum+data[i];
			}else {
				sum = sum-data[i];
			} n % 2 == 0 n % 2 n 2 0 {
				sum = sum+data[i];
			} sum = sum+data[i] sum sum+data[i] sum data[i] data i {
				sum = sum-data[i];
			} sum = sum-data[i] sum sum-data[i] sum data[i] data i n++ n System.out.println(sum) System.out.println System.out System System.out sum sc.close() sc.close sc String[] args args public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int data[] = new int[N];
		for(int i = 0; i < N; i++) {
			data[i] = sc.nextInt();
		}
		Arrays.sort(data);
		int sum = 0;
		int n = 2;
		for(int i = N-1; i >= 0; i--) {
			if(n % 2 == 0) {
				sum = sum+data[i];
			}else {
				sum = sum-data[i];
			}
			n++;
		}
		System.out.println(sum);
		sc.close();
	}
} public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int data[] = new int[N];
		for(int i = 0; i < N; i++) {
			data[i] = sc.nextInt();
		}
		Arrays.sort(data);
		int sum = 0;
		int n = 2;
		for(int i = N-1; i >= 0; i--) {
			if(n % 2 == 0) {
				sum = sum+data[i];
			}else {
				sum = sum-data[i];
			}
			n++;
		}
		System.out.println(sum);
		sc.close();
	}
} Main
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int data[] = new int[N];
		for(int i = 0; i < N; i++) {
			data[i] = sc.nextInt();
		}
		Arrays.sort(data);
		int sum = 0;
		int n = 2;
		for(int i = N-1; i >= 0; i--) {
			if(n % 2 == 0) {
				sum = sum+data[i];
			}else {
				sum = sum-data[i];
			}
			n++;
		}
		System.out.println(sum);
		sc.close();
	}
}
