import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC088B solver = new ABC088B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC088B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int n = Integer.parseInt(in.next());
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            Arrays.sort(a, Comparator.reverseOrder());
            int alice = 0;
            int bob = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    alice += a[i];
                } else {
                    bob += a[i];
                }
            }
            int ans = alice - bob;

            // 出力
            out.println(ans);
        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util import java.util.Comparator; Comparator java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC088B solver = new ABC088B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC088B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int n = Integer.parseInt(in.next());
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            Arrays.sort(a, Comparator.reverseOrder());
            int alice = 0;
            int bob = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    alice += a[i];
                } else {
                    bob += a[i];
                }
            }
            int ans = alice - bob;

            // 出力
            out.println(ans);
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC088B solver = new ABC088B();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC088B solver = new ABC088B();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) ABC088B solver = new ABC088B(); solver new ABC088B() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class ABC088B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int n = Integer.parseInt(in.next());
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            Arrays.sort(a, Comparator.reverseOrder());
            int alice = 0;
            int bob = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    alice += a[i];
                } else {
                    bob += a[i];
                }
            }
            int ans = alice - bob;

            // 出力
            out.println(ans);
        }

    } ABC088B public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int n = Integer.parseInt(in.next());
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            Arrays.sort(a, Comparator.reverseOrder());
            int alice = 0;
            int bob = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    alice += a[i];
                } else {
                    bob += a[i];
                }
            }
            int ans = alice - bob;

            // 出力
            out.println(ans);
        } solve {
            // 整数の入力
            int n = Integer.parseInt(in.next());
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            Arrays.sort(a, Comparator.reverseOrder());
            int alice = 0;
            int bob = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    alice += a[i];
                } else {
                    bob += a[i];
                }
            }
            int ans = alice - bob;

            // 出力
            out.println(ans);
        } int n = Integer.parseInt(in.next()); n Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in Integer[] a = new Integer[n]; a new Integer[n] n for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                a[i] = Integer.parseInt(in.next());
            } {
                a[i] = Integer.parseInt(in.next());
            } a[i] = Integer.parseInt(in.next()) a[i] a i Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in Arrays.sort(a, Comparator.reverseOrder()) Arrays.sort Arrays a 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 += a[i];
                } else {
                    bob += a[i];
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                if (i % 2 == 0) {
                    alice += a[i];
                } else {
                    bob += a[i];
                }
            } {
                if (i % 2 == 0) {
                    alice += a[i];
                } else {
                    bob += a[i];
                }
            } if (i % 2 == 0) {
                    alice += a[i];
                } else {
                    bob += a[i];
                } i % 2 == 0 i % 2 i 2 0 {
                    alice += a[i];
                } alice += a[i] alice a[i] a i {
                    bob += a[i];
                } bob += a[i] bob a[i] a i int ans = alice - bob; ans alice - bob alice bob out.println(ans) out.println out ans int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC088B solver = new ABC088B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC088B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int n = Integer.parseInt(in.next());
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            Arrays.sort(a, Comparator.reverseOrder());
            int alice = 0;
            int bob = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    alice += a[i];
                } else {
                    bob += a[i];
                }
            }
            int ans = alice - bob;

            // 出力
            out.println(ans);
        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC088B solver = new ABC088B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC088B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int n = Integer.parseInt(in.next());
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            Arrays.sort(a, Comparator.reverseOrder());
            int alice = 0;
            int bob = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    alice += a[i];
                } else {
                    bob += a[i];
                }
            }
            int ans = alice - bob;

            // 出力
            out.println(ans);
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC088B solver = new ABC088B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC088B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int n = Integer.parseInt(in.next());
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            Arrays.sort(a, Comparator.reverseOrder());
            int alice = 0;
            int bob = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    alice += a[i];
                } else {
                    bob += a[i];
                }
            }
            int ans = alice - bob;

            // 出力
            out.println(ans);
        }

    }
}

