import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		List<Integer> a = new ArrayList<>();

		for(int i=0; i<N; i++) {
			a.add(sc.nextInt());
		}

		Collections.sort(a, Comparator.reverseOrder());

		int alice = 0;
		int bob = 0;
		for(int i=0; i<N; i++) {
			if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i);
		}

		println(alice - bob);

	}

	public static void print(Object o) {
		System.out.print(o);
	}

	public static void println(Object o) {
		System.out.println(o);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		List<Integer> a = new ArrayList<>();

		for(int i=0; i<N; i++) {
			a.add(sc.nextInt());
		}

		Collections.sort(a, Comparator.reverseOrder());

		int alice = 0;
		int bob = 0;
		for(int i=0; i<N; i++) {
			if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i);
		}

		println(alice - bob);

	}

	public static void print(Object o) {
		System.out.print(o);
	}

	public static void println(Object o) {
		System.out.println(o);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		List<Integer> a = new ArrayList<>();

		for(int i=0; i<N; i++) {
			a.add(sc.nextInt());
		}

		Collections.sort(a, Comparator.reverseOrder());

		int alice = 0;
		int bob = 0;
		for(int i=0; i<N; i++) {
			if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i);
		}

		println(alice - bob);

	} main {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		List<Integer> a = new ArrayList<>();

		for(int i=0; i<N; i++) {
			a.add(sc.nextInt());
		}

		Collections.sort(a, Comparator.reverseOrder());

		int alice = 0;
		int bob = 0;
		for(int i=0; i<N; i++) {
			if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i);
		}

		println(alice - bob);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc List<Integer> a = new ArrayList<>(); a new ArrayList<>() for(int i=0; i<N; i++) {
			a.add(sc.nextInt());
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			a.add(sc.nextInt());
		} {
			a.add(sc.nextInt());
		} a.add(sc.nextInt()) a.add a sc.nextInt() sc.nextInt sc Collections.sort(a, Comparator.reverseOrder()) Collections.sort Collections a Comparator.reverseOrder() Comparator.reverseOrder Comparator int alice = 0; alice 0 int bob = 0; bob 0 for(int i=0; i<N; i++) {
			if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i);
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i);
		} {
			if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i);
		} if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i); i%2 == 0 i%2 i 2 0 alice += a.get(i) alice a.get(i) a.get a i bob += a.get(i) bob a.get(i) a.get a i println(alice - bob) println alice - bob alice bob String[] args args public static void print(Object o) {
		System.out.print(o);
	} print {
		System.out.print(o);
	} System.out.print(o) System.out.print System.out System System.out o Object o o public static void println(Object o) {
		System.out.println(o);
	} println {
		System.out.println(o);
	} System.out.println(o) System.out.println System.out System System.out o Object o o public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		List<Integer> a = new ArrayList<>();

		for(int i=0; i<N; i++) {
			a.add(sc.nextInt());
		}

		Collections.sort(a, Comparator.reverseOrder());

		int alice = 0;
		int bob = 0;
		for(int i=0; i<N; i++) {
			if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i);
		}

		println(alice - bob);

	}

	public static void print(Object o) {
		System.out.print(o);
	}

	public static void println(Object o) {
		System.out.println(o);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		List<Integer> a = new ArrayList<>();

		for(int i=0; i<N; i++) {
			a.add(sc.nextInt());
		}

		Collections.sort(a, Comparator.reverseOrder());

		int alice = 0;
		int bob = 0;
		for(int i=0; i<N; i++) {
			if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i);
		}

		println(alice - bob);

	}

	public static void print(Object o) {
		System.out.print(o);
	}

	public static void println(Object o) {
		System.out.println(o);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		List<Integer> a = new ArrayList<>();

		for(int i=0; i<N; i++) {
			a.add(sc.nextInt());
		}

		Collections.sort(a, Comparator.reverseOrder());

		int alice = 0;
		int bob = 0;
		for(int i=0; i<N; i++) {
			if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i);
		}

		println(alice - bob);

	}

	public static void print(Object o) {
		System.out.print(o);
	}

	public static void println(Object o) {
		System.out.println(o);
	}
}