import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        // Alice,Bob got poit.
        int a = 0;
        int b = 0;
        boolean isAlice = true;
        for (int i = list.size()-1; i >= 0; i--){
            if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            }
            isAlice = !isAlice;
        }
        // 出力
        System.out.println(a-b);
    }
} 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> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        // Alice,Bob got poit.
        int a = 0;
        int b = 0;
        boolean isAlice = true;
        for (int i = list.size()-1; i >= 0; i--){
            if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            }
            isAlice = !isAlice;
        }
        // 出力
        System.out.println(a-b);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        // Alice,Bob got poit.
        int a = 0;
        int b = 0;
        boolean isAlice = true;
        for (int i = list.size()-1; i >= 0; i--){
            if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            }
            isAlice = !isAlice;
        }
        // 出力
        System.out.println(a-b);
    } main {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        // Alice,Bob got poit.
        int a = 0;
        int b = 0;
        boolean isAlice = true;
        for (int i = list.size()-1; i >= 0; i--){
            if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            }
            isAlice = !isAlice;
        }
        // 出力
        System.out.println(a-b);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc List<Integer> list = new ArrayList<>(); list new ArrayList<>() for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            list.add(sc.nextInt());
        } {
            list.add(sc.nextInt());
        } list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc Collections.sort(list) Collections.sort Collections list int a = 0; a 0 int b = 0; b 0 boolean isAlice = true; isAlice true for (int i = list.size()-1; i >= 0; i--){
            if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            }
            isAlice = !isAlice;
        } int i = list.size()-1; int i = list.size()-1; i list.size()-1 list.size() list.size list 1 i >= 0 i 0 i-- i-- i {
            if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            }
            isAlice = !isAlice;
        } {
            if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            }
            isAlice = !isAlice;
        } if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            } isAlice {
                a += list.get(i);
            } a += list.get(i) a list.get(i) list.get list i {
                b += list.get(i);
            } b += list.get(i) b list.get(i) list.get list i isAlice = !isAlice isAlice !isAlice isAlice System.out.println(a-b) System.out.println System.out System System.out a-b a b String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        // Alice,Bob got poit.
        int a = 0;
        int b = 0;
        boolean isAlice = true;
        for (int i = list.size()-1; i >= 0; i--){
            if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            }
            isAlice = !isAlice;
        }
        // 出力
        System.out.println(a-b);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        // Alice,Bob got poit.
        int a = 0;
        int b = 0;
        boolean isAlice = true;
        for (int i = list.size()-1; i >= 0; i--){
            if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            }
            isAlice = !isAlice;
        }
        // 出力
        System.out.println(a-b);
    }
} 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> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        // Alice,Bob got poit.
        int a = 0;
        int b = 0;
        boolean isAlice = true;
        for (int i = list.size()-1; i >= 0; i--){
            if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            }
            isAlice = !isAlice;
        }
        // 出力
        System.out.println(a-b);
    }
}
