import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> a = new ArrayList();

        for (int i = 0; i < N; i++) {
            a.add(sc.nextInt());
        }
        sc.close();
        a.sort(Collections.reverseOrder());

        int Alice = 0;
        int Bob = 0;

        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            }
        }

        System.out.println(Alice - Bob);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> a = new ArrayList();

        for (int i = 0; i < N; i++) {
            a.add(sc.nextInt());
        }
        sc.close();
        a.sort(Collections.reverseOrder());

        int Alice = 0;
        int Bob = 0;

        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            }
        }

        System.out.println(Alice - Bob);
    }
} Main public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> a = new ArrayList();

        for (int i = 0; i < N; i++) {
            a.add(sc.nextInt());
        }
        sc.close();
        a.sort(Collections.reverseOrder());

        int Alice = 0;
        int Bob = 0;

        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            }
        }

        System.out.println(Alice - Bob);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> a = new ArrayList();

        for (int i = 0; i < N; i++) {
            a.add(sc.nextInt());
        }
        sc.close();
        a.sort(Collections.reverseOrder());

        int Alice = 0;
        int Bob = 0;

        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            }
        }

        System.out.println(Alice - Bob);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc ArrayList<Integer> a = new ArrayList(); a new ArrayList() for (int i = 0; i < N; i++) {
            a.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            a.add(sc.nextInt());
        } {
            a.add(sc.nextInt());
        } a.add(sc.nextInt()) a.add a sc.nextInt() sc.nextInt sc sc.close() sc.close sc a.sort(Collections.reverseOrder()) a.sort a Collections.reverseOrder() Collections.reverseOrder Collections int Alice = 0; Alice 0 int Bob = 0; Bob 0 for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            }
        } {
            if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            }
        } if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            } i % 2 == 0 i % 2 i 2 0 {
                Alice += a.get(i);
            } Alice += a.get(i) Alice a.get(i) a.get a i {
                Bob += a.get(i);
            } Bob += a.get(i) Bob a.get(i) a.get a i System.out.println(Alice - Bob) System.out.println System.out System System.out Alice - Bob Alice Bob String... args args public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> a = new ArrayList();

        for (int i = 0; i < N; i++) {
            a.add(sc.nextInt());
        }
        sc.close();
        a.sort(Collections.reverseOrder());

        int Alice = 0;
        int Bob = 0;

        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            }
        }

        System.out.println(Alice - Bob);
    }
} public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> a = new ArrayList();

        for (int i = 0; i < N; i++) {
            a.add(sc.nextInt());
        }
        sc.close();
        a.sort(Collections.reverseOrder());

        int Alice = 0;
        int Bob = 0;

        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            }
        }

        System.out.println(Alice - Bob);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> a = new ArrayList();

        for (int i = 0; i < N; i++) {
            a.add(sc.nextInt());
        }
        sc.close();
        a.sort(Collections.reverseOrder());

        int Alice = 0;
        int Bob = 0;

        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            }
        }

        System.out.println(Alice - Bob);
    }
}