import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		PriorityQueue<Integer> pq = new PriorityQueue<>(100, Collections.reverseOrder());
		for (int i=0; i<n; i++ ) {
			pq.add(sc.nextInt());
		}
		int i=0;
		long sum = 0l;
		while (i<n) {
			if (i%2 == 0) {
				sum += pq.poll();
			} else {
				sum -= pq.poll();
			}
			i++;
		}
		System.out.println(sum);
		sc.close();
	}

} import java.util.Collections; Collections java.util import java.util.PriorityQueue; PriorityQueue 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();
		PriorityQueue<Integer> pq = new PriorityQueue<>(100, Collections.reverseOrder());
		for (int i=0; i<n; i++ ) {
			pq.add(sc.nextInt());
		}
		int i=0;
		long sum = 0l;
		while (i<n) {
			if (i%2 == 0) {
				sum += pq.poll();
			} else {
				sum -= pq.poll();
			}
			i++;
		}
		System.out.println(sum);
		sc.close();
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		PriorityQueue<Integer> pq = new PriorityQueue<>(100, Collections.reverseOrder());
		for (int i=0; i<n; i++ ) {
			pq.add(sc.nextInt());
		}
		int i=0;
		long sum = 0l;
		while (i<n) {
			if (i%2 == 0) {
				sum += pq.poll();
			} else {
				sum -= pq.poll();
			}
			i++;
		}
		System.out.println(sum);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		PriorityQueue<Integer> pq = new PriorityQueue<>(100, Collections.reverseOrder());
		for (int i=0; i<n; i++ ) {
			pq.add(sc.nextInt());
		}
		int i=0;
		long sum = 0l;
		while (i<n) {
			if (i%2 == 0) {
				sum += pq.poll();
			} else {
				sum -= pq.poll();
			}
			i++;
		}
		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 PriorityQueue<Integer> pq = new PriorityQueue<>(100, Collections.reverseOrder()); pq new PriorityQueue<>(100, Collections.reverseOrder()) for (int i=0; i<n; i++ ) {
			pq.add(sc.nextInt());
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			pq.add(sc.nextInt());
		} {
			pq.add(sc.nextInt());
		} pq.add(sc.nextInt()) pq.add pq sc.nextInt() sc.nextInt sc int i=0; i 0 long sum = 0l; sum 0l while (i<n) {
			if (i%2 == 0) {
				sum += pq.poll();
			} else {
				sum -= pq.poll();
			}
			i++;
		} i<n i n {
			if (i%2 == 0) {
				sum += pq.poll();
			} else {
				sum -= pq.poll();
			}
			i++;
		} if (i%2 == 0) {
				sum += pq.poll();
			} else {
				sum -= pq.poll();
			} i%2 == 0 i%2 i 2 0 {
				sum += pq.poll();
			} sum += pq.poll() sum pq.poll() pq.poll pq {
				sum -= pq.poll();
			} sum -= pq.poll() sum pq.poll() pq.poll pq i++ i 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();
		PriorityQueue<Integer> pq = new PriorityQueue<>(100, Collections.reverseOrder());
		for (int i=0; i<n; i++ ) {
			pq.add(sc.nextInt());
		}
		int i=0;
		long sum = 0l;
		while (i<n) {
			if (i%2 == 0) {
				sum += pq.poll();
			} else {
				sum -= pq.poll();
			}
			i++;
		}
		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();
		PriorityQueue<Integer> pq = new PriorityQueue<>(100, Collections.reverseOrder());
		for (int i=0; i<n; i++ ) {
			pq.add(sc.nextInt());
		}
		int i=0;
		long sum = 0l;
		while (i<n) {
			if (i%2 == 0) {
				sum += pq.poll();
			} else {
				sum -= pq.poll();
			}
			i++;
		}
		System.out.println(sum);
		sc.close();
	}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		PriorityQueue<Integer> pq = new PriorityQueue<>(100, Collections.reverseOrder());
		for (int i=0; i<n; i++ ) {
			pq.add(sc.nextInt());
		}
		int i=0;
		long sum = 0l;
		while (i<n) {
			if (i%2 == 0) {
				sum += pq.poll();
			} else {
				sum -= pq.poll();
			}
			i++;
		}
		System.out.println(sum);
		sc.close();
	}

}
