import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        Integer[] cards = new Integer[count];

        for (int i = 0; i < count; i++) {
            cards[i] = sc.nextInt();
        }

        // 降順にする
        Arrays.sort(cards, Collections.reverseOrder());

        int score = 0;
        for (int i = 0; i < cards.length; i++) {
            if (i % 2 == 0) {
                score += cards[i];
            } else {
                score -= cards[i];
            }
        }

        System.out.println(score);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        Integer[] cards = new Integer[count];

        for (int i = 0; i < count; i++) {
            cards[i] = sc.nextInt();
        }

        // 降順にする
        Arrays.sort(cards, Collections.reverseOrder());

        int score = 0;
        for (int i = 0; i < cards.length; i++) {
            if (i % 2 == 0) {
                score += cards[i];
            } else {
                score -= cards[i];
            }
        }

        System.out.println(score);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        Integer[] cards = new Integer[count];

        for (int i = 0; i < count; i++) {
            cards[i] = sc.nextInt();
        }

        // 降順にする
        Arrays.sort(cards, Collections.reverseOrder());

        int score = 0;
        for (int i = 0; i < cards.length; i++) {
            if (i % 2 == 0) {
                score += cards[i];
            } else {
                score -= cards[i];
            }
        }

        System.out.println(score);
    } main {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        Integer[] cards = new Integer[count];

        for (int i = 0; i < count; i++) {
            cards[i] = sc.nextInt();
        }

        // 降順にする
        Arrays.sort(cards, Collections.reverseOrder());

        int score = 0;
        for (int i = 0; i < cards.length; i++) {
            if (i % 2 == 0) {
                score += cards[i];
            } else {
                score -= cards[i];
            }
        }

        System.out.println(score);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count = sc.nextInt(); count sc.nextInt() sc.nextInt sc Integer[] cards = new Integer[count]; cards new Integer[count] count for (int i = 0; i < count; i++) {
            cards[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < count i count i++ i++ i {
            cards[i] = sc.nextInt();
        } {
            cards[i] = sc.nextInt();
        } cards[i] = sc.nextInt() cards[i] cards i sc.nextInt() sc.nextInt sc Arrays.sort(cards, Collections.reverseOrder()) Arrays.sort Arrays cards Collections.reverseOrder() Collections.reverseOrder Collections int score = 0; score 0 for (int i = 0; i < cards.length; i++) {
            if (i % 2 == 0) {
                score += cards[i];
            } else {
                score -= cards[i];
            }
        } int i = 0; int i = 0; i 0 i < cards.length i cards.length cards cards.length i++ i++ i {
            if (i % 2 == 0) {
                score += cards[i];
            } else {
                score -= cards[i];
            }
        } {
            if (i % 2 == 0) {
                score += cards[i];
            } else {
                score -= cards[i];
            }
        } if (i % 2 == 0) {
                score += cards[i];
            } else {
                score -= cards[i];
            } i % 2 == 0 i % 2 i 2 0 {
                score += cards[i];
            } score += cards[i] score cards[i] cards i {
                score -= cards[i];
            } score -= cards[i] score cards[i] cards i System.out.println(score) System.out.println System.out System System.out score String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        Integer[] cards = new Integer[count];

        for (int i = 0; i < count; i++) {
            cards[i] = sc.nextInt();
        }

        // 降順にする
        Arrays.sort(cards, Collections.reverseOrder());

        int score = 0;
        for (int i = 0; i < cards.length; i++) {
            if (i % 2 == 0) {
                score += cards[i];
            } else {
                score -= cards[i];
            }
        }

        System.out.println(score);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        Integer[] cards = new Integer[count];

        for (int i = 0; i < count; i++) {
            cards[i] = sc.nextInt();
        }

        // 降順にする
        Arrays.sort(cards, Collections.reverseOrder());

        int score = 0;
        for (int i = 0; i < cards.length; i++) {
            if (i % 2 == 0) {
                score += cards[i];
            } else {
                score -= cards[i];
            }
        }

        System.out.println(score);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        Integer[] cards = new Integer[count];

        for (int i = 0; i < count; i++) {
            cards[i] = sc.nextInt();
        }

        // 降順にする
        Arrays.sort(cards, Collections.reverseOrder());

        int score = 0;
        for (int i = 0; i < cards.length; i++) {
            if (i % 2 == 0) {
                score += cards[i];
            } else {
                score -= cards[i];
            }
        }

        System.out.println(score);
    }
}
