import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> cards = new ArrayList<Integer>();
		for(int i = 0;i < n ;i++) {
			cards.add(sc.nextInt());
		}
		Collections.sort(cards);
		Collections.reverse(cards);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(i % 2 == 0) ans += cards.get(i);
			else ans -= cards.get(i);
		}
		System.out.println(ans);
        sc.close();
	}
} 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> cards = new ArrayList<Integer>();
		for(int i = 0;i < n ;i++) {
			cards.add(sc.nextInt());
		}
		Collections.sort(cards);
		Collections.reverse(cards);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(i % 2 == 0) ans += cards.get(i);
			else ans -= cards.get(i);
		}
		System.out.println(ans);
        sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> cards = new ArrayList<Integer>();
		for(int i = 0;i < n ;i++) {
			cards.add(sc.nextInt());
		}
		Collections.sort(cards);
		Collections.reverse(cards);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(i % 2 == 0) ans += cards.get(i);
			else ans -= cards.get(i);
		}
		System.out.println(ans);
        sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> cards = new ArrayList<Integer>();
		for(int i = 0;i < n ;i++) {
			cards.add(sc.nextInt());
		}
		Collections.sort(cards);
		Collections.reverse(cards);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(i % 2 == 0) ans += cards.get(i);
			else ans -= cards.get(i);
		}
		System.out.println(ans);
        sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc List<Integer> cards = new ArrayList<Integer>(); cards new ArrayList<Integer>() for(int i = 0;i < n ;i++) {
			cards.add(sc.nextInt());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			cards.add(sc.nextInt());
		} {
			cards.add(sc.nextInt());
		} cards.add(sc.nextInt()) cards.add cards sc.nextInt() sc.nextInt sc Collections.sort(cards) Collections.sort Collections cards Collections.reverse(cards) Collections.reverse Collections cards int ans = 0; ans 0 for(int i = 0;i < n;i++) {
			if(i % 2 == 0) ans += cards.get(i);
			else ans -= cards.get(i);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			if(i % 2 == 0) ans += cards.get(i);
			else ans -= cards.get(i);
		} {
			if(i % 2 == 0) ans += cards.get(i);
			else ans -= cards.get(i);
		} if(i % 2 == 0) ans += cards.get(i);
			else ans -= cards.get(i); i % 2 == 0 i % 2 i 2 0 ans += cards.get(i) ans cards.get(i) cards.get cards i ans -= cards.get(i) ans cards.get(i) cards.get cards i System.out.println(ans) System.out.println System.out System System.out ans 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();
		List<Integer> cards = new ArrayList<Integer>();
		for(int i = 0;i < n ;i++) {
			cards.add(sc.nextInt());
		}
		Collections.sort(cards);
		Collections.reverse(cards);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(i % 2 == 0) ans += cards.get(i);
			else ans -= cards.get(i);
		}
		System.out.println(ans);
        sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> cards = new ArrayList<Integer>();
		for(int i = 0;i < n ;i++) {
			cards.add(sc.nextInt());
		}
		Collections.sort(cards);
		Collections.reverse(cards);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(i % 2 == 0) ans += cards.get(i);
			else ans -= cards.get(i);
		}
		System.out.println(ans);
        sc.close();
	}
} 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> cards = new ArrayList<Integer>();
		for(int i = 0;i < n ;i++) {
			cards.add(sc.nextInt());
		}
		Collections.sort(cards);
		Collections.reverse(cards);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(i % 2 == 0) ans += cards.get(i);
			else ans -= cards.get(i);
		}
		System.out.println(ans);
        sc.close();
	}
}