import java.util.*;
import java.util.stream.Collectors;

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

        List<Integer> sortedCards = cards.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
        int alicePoints = 0;
        int bobPoints = 0;

        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                alicePoints += sortedCards.get(i);
            } else {
                bobPoints += sortedCards.get(i);
            }
        }
        System.out.println(alicePoints - bobPoints);
    }
} import java.util.*; util.* java import java.util.stream.Collectors; Collectors java.util.stream class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
      
        int n = sc.nextInt();
        ArrayList<Integer> cards = new ArrayList<>();
        for(int i = 0;i < n; i++) {
        cards.add(sc.nextInt());
        }

        List<Integer> sortedCards = cards.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
        int alicePoints = 0;
        int bobPoints = 0;

        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                alicePoints += sortedCards.get(i);
            } else {
                bobPoints += sortedCards.get(i);
            }
        }
        System.out.println(alicePoints - bobPoints);
    }
} Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
      
        int n = sc.nextInt();
        ArrayList<Integer> cards = new ArrayList<>();
        for(int i = 0;i < n; i++) {
        cards.add(sc.nextInt());
        }

        List<Integer> sortedCards = cards.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
        int alicePoints = 0;
        int bobPoints = 0;

        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                alicePoints += sortedCards.get(i);
            } else {
                bobPoints += sortedCards.get(i);
            }
        }
        System.out.println(alicePoints - bobPoints);
    } main {
        Scanner sc = new Scanner(System.in);
      
        int n = sc.nextInt();
        ArrayList<Integer> cards = new ArrayList<>();
        for(int i = 0;i < n; i++) {
        cards.add(sc.nextInt());
        }

        List<Integer> sortedCards = cards.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
        int alicePoints = 0;
        int bobPoints = 0;

        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                alicePoints += sortedCards.get(i);
            } else {
                bobPoints += sortedCards.get(i);
            }
        }
        System.out.println(alicePoints - bobPoints);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc ArrayList<Integer> cards = new ArrayList<>(); cards new ArrayList<>() 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 List<Integer> sortedCards = cards.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList()); sortedCards cards.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList()) cards.stream().sorted(Comparator.reverseOrder()).collect cards.stream().sorted(Comparator.reverseOrder()) cards.stream().sorted cards.stream() cards.stream cards Comparator.reverseOrder() Comparator.reverseOrder Comparator Collectors.toList() Collectors.toList Collectors int alicePoints = 0; alicePoints 0 int bobPoints = 0; bobPoints 0 for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                alicePoints += sortedCards.get(i);
            } else {
                bobPoints += sortedCards.get(i);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if (i % 2 == 0) {
                alicePoints += sortedCards.get(i);
            } else {
                bobPoints += sortedCards.get(i);
            }
        } {
            if (i % 2 == 0) {
                alicePoints += sortedCards.get(i);
            } else {
                bobPoints += sortedCards.get(i);
            }
        } if (i % 2 == 0) {
                alicePoints += sortedCards.get(i);
            } else {
                bobPoints += sortedCards.get(i);
            } i % 2 == 0 i % 2 i 2 0 {
                alicePoints += sortedCards.get(i);
            } alicePoints += sortedCards.get(i) alicePoints sortedCards.get(i) sortedCards.get sortedCards i {
                bobPoints += sortedCards.get(i);
            } bobPoints += sortedCards.get(i) bobPoints sortedCards.get(i) sortedCards.get sortedCards i System.out.println(alicePoints - bobPoints) System.out.println System.out System System.out alicePoints - bobPoints alicePoints bobPoints String args[] args
import java.util.*;
import java.util.stream.Collectors;

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

        List<Integer> sortedCards = cards.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
        int alicePoints = 0;
        int bobPoints = 0;

        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                alicePoints += sortedCards.get(i);
            } else {
                bobPoints += sortedCards.get(i);
            }
        }
        System.out.println(alicePoints - bobPoints);
    }
}