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<>();
        int alliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            cards.add(sc.nextInt());
        }
        Collections.sort(cards, Comparator.reverseOrder());

        int current = 2;
        while (cards.size() > 0) {
            if (current % 2 == 0) {
                alliceSum += cards.get(0);
            } else {
                bobSum += cards.get(0);
            }
            cards.remove(0);
            current++;
        }

        System.out.println(alliceSum - bobSum);

    }
} 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<>();
        int alliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            cards.add(sc.nextInt());
        }
        Collections.sort(cards, Comparator.reverseOrder());

        int current = 2;
        while (cards.size() > 0) {
            if (current % 2 == 0) {
                alliceSum += cards.get(0);
            } else {
                bobSum += cards.get(0);
            }
            cards.remove(0);
            current++;
        }

        System.out.println(alliceSum - bobSum);

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> cards = new ArrayList<>();
        int alliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            cards.add(sc.nextInt());
        }
        Collections.sort(cards, Comparator.reverseOrder());

        int current = 2;
        while (cards.size() > 0) {
            if (current % 2 == 0) {
                alliceSum += cards.get(0);
            } else {
                bobSum += cards.get(0);
            }
            cards.remove(0);
            current++;
        }

        System.out.println(alliceSum - bobSum);

    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> cards = new ArrayList<>();
        int alliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            cards.add(sc.nextInt());
        }
        Collections.sort(cards, Comparator.reverseOrder());

        int current = 2;
        while (cards.size() > 0) {
            if (current % 2 == 0) {
                alliceSum += cards.get(0);
            } else {
                bobSum += cards.get(0);
            }
            cards.remove(0);
            current++;
        }

        System.out.println(alliceSum - bobSum);

    } 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<>(); cards new ArrayList<>() int alliceSum = 0; alliceSum 0 int bobSum = 0; bobSum 0 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, Comparator.reverseOrder()) Collections.sort Collections cards Comparator.reverseOrder() Comparator.reverseOrder Comparator int current = 2; current 2 while (cards.size() > 0) {
            if (current % 2 == 0) {
                alliceSum += cards.get(0);
            } else {
                bobSum += cards.get(0);
            }
            cards.remove(0);
            current++;
        } cards.size() > 0 cards.size() cards.size cards 0 {
            if (current % 2 == 0) {
                alliceSum += cards.get(0);
            } else {
                bobSum += cards.get(0);
            }
            cards.remove(0);
            current++;
        } if (current % 2 == 0) {
                alliceSum += cards.get(0);
            } else {
                bobSum += cards.get(0);
            } current % 2 == 0 current % 2 current 2 0 {
                alliceSum += cards.get(0);
            } alliceSum += cards.get(0) alliceSum cards.get(0) cards.get cards 0 {
                bobSum += cards.get(0);
            } bobSum += cards.get(0) bobSum cards.get(0) cards.get cards 0 cards.remove(0) cards.remove cards 0 current++ current System.out.println(alliceSum - bobSum) System.out.println System.out System System.out alliceSum - bobSum alliceSum bobSum 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<>();
        int alliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            cards.add(sc.nextInt());
        }
        Collections.sort(cards, Comparator.reverseOrder());

        int current = 2;
        while (cards.size() > 0) {
            if (current % 2 == 0) {
                alliceSum += cards.get(0);
            } else {
                bobSum += cards.get(0);
            }
            cards.remove(0);
            current++;
        }

        System.out.println(alliceSum - bobSum);

    }
} public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> cards = new ArrayList<>();
        int alliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            cards.add(sc.nextInt());
        }
        Collections.sort(cards, Comparator.reverseOrder());

        int current = 2;
        while (cards.size() > 0) {
            if (current % 2 == 0) {
                alliceSum += cards.get(0);
            } else {
                bobSum += cards.get(0);
            }
            cards.remove(0);
            current++;
        }

        System.out.println(alliceSum - bobSum);

    }
} 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<>();
        int alliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            cards.add(sc.nextInt());
        }
        Collections.sort(cards, Comparator.reverseOrder());

        int current = 2;
        while (cards.size() > 0) {
            if (current % 2 == 0) {
                alliceSum += cards.get(0);
            } else {
                bobSum += cards.get(0);
            }
            cards.remove(0);
            current++;
        }

        System.out.println(alliceSum - bobSum);

    }
}