import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.nextLine());
        Integer[] an = new Integer[N];
        for (int i = 0; i < N; i++) {
            an[i] = Integer.parseInt(sc.next());
        }

        // 効率よくカードを引くのでソートする
        Arrays.sort(an, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                alice += an[i];
            } else {
                bob += an[i];
            }

        }

        System.out.println(alice - bob);
    }
} import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.nextLine());
        Integer[] an = new Integer[N];
        for (int i = 0; i < N; i++) {
            an[i] = Integer.parseInt(sc.next());
        }

        // 効率よくカードを引くのでソートする
        Arrays.sort(an, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                alice += an[i];
            } else {
                bob += an[i];
            }

        }

        System.out.println(alice - bob);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.nextLine());
        Integer[] an = new Integer[N];
        for (int i = 0; i < N; i++) {
            an[i] = Integer.parseInt(sc.next());
        }

        // 効率よくカードを引くのでソートする
        Arrays.sort(an, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                alice += an[i];
            } else {
                bob += an[i];
            }

        }

        System.out.println(alice - bob);
    } main {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.nextLine());
        Integer[] an = new Integer[N];
        for (int i = 0; i < N; i++) {
            an[i] = Integer.parseInt(sc.next());
        }

        // 効率よくカードを引くのでソートする
        Arrays.sort(an, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                alice += an[i];
            } else {
                bob += an[i];
            }

        }

        System.out.println(alice - bob);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.nextLine()); N Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc Integer[] an = new Integer[N]; an new Integer[N] N for (int i = 0; i < N; i++) {
            an[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            an[i] = Integer.parseInt(sc.next());
        } {
            an[i] = Integer.parseInt(sc.next());
        } an[i] = Integer.parseInt(sc.next()) an[i] an i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(an, Comparator.reverseOrder()) Arrays.sort Arrays an Comparator.reverseOrder() Comparator.reverseOrder Comparator int alice = 0; alice 0 int bob = 0; bob 0 for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                alice += an[i];
            } else {
                bob += an[i];
            }

        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if (i % 2 == 0) {
                alice += an[i];
            } else {
                bob += an[i];
            }

        } {
            if (i % 2 == 0) {
                alice += an[i];
            } else {
                bob += an[i];
            }

        } if (i % 2 == 0) {
                alice += an[i];
            } else {
                bob += an[i];
            } i % 2 == 0 i % 2 i 2 0 {
                alice += an[i];
            } alice += an[i] alice an[i] an i {
                bob += an[i];
            } bob += an[i] bob an[i] an 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 = Integer.parseInt(sc.nextLine());
        Integer[] an = new Integer[N];
        for (int i = 0; i < N; i++) {
            an[i] = Integer.parseInt(sc.next());
        }

        // 効率よくカードを引くのでソートする
        Arrays.sort(an, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                alice += an[i];
            } else {
                bob += an[i];
            }

        }

        System.out.println(alice - bob);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.nextLine());
        Integer[] an = new Integer[N];
        for (int i = 0; i < N; i++) {
            an[i] = Integer.parseInt(sc.next());
        }

        // 効率よくカードを引くのでソートする
        Arrays.sort(an, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                alice += an[i];
            } else {
                bob += an[i];
            }

        }

        System.out.println(alice - bob);
    }
} Main
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.nextLine());
        Integer[] an = new Integer[N];
        for (int i = 0; i < N; i++) {
            an[i] = Integer.parseInt(sc.next());
        }

        // 効率よくカードを引くのでソートする
        Arrays.sort(an, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                alice += an[i];
            } else {
                bob += an[i];
            }

        }

        System.out.println(alice - bob);
    }
}
