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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = Integer.parseInt(in.next());
            Integer a[] = new Integer[N];
            for (byte 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 += 2) {
                Alice += a[i];
            }
            for (int i = 1; i < N; i += 2) {
                Bob += a[i];
            }
            out.println(Alice - Bob);
        }

    }
}
 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = Integer.parseInt(in.next());
            Integer a[] = new Integer[N];
            for (byte 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 += 2) {
                Alice += a[i];
            }
            for (int i = 1; i < N; i += 2) {
                Bob += a[i];
            }
            out.println(Alice - Bob);
        }

    }
} 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);
        B solver = new B();
        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);
        B solver = new B();
        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) B solver = new B(); solver new B() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = Integer.parseInt(in.next());
            Integer a[] = new Integer[N];
            for (byte 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 += 2) {
                Alice += a[i];
            }
            for (int i = 1; i < N; i += 2) {
                Bob += a[i];
            }
            out.println(Alice - Bob);
        }

    } B public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = Integer.parseInt(in.next());
            Integer a[] = new Integer[N];
            for (byte 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 += 2) {
                Alice += a[i];
            }
            for (int i = 1; i < N; i += 2) {
                Bob += a[i];
            }
            out.println(Alice - Bob);
        } solve {
            int N = Integer.parseInt(in.next());
            Integer a[] = new Integer[N];
            for (byte 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 += 2) {
                Alice += a[i];
            }
            for (int i = 1; i < N; i += 2) {
                Bob += a[i];
            }
            out.println(Alice - Bob);
        } 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 (byte i = 0; i < N; i++) {
                a[i] = Integer.parseInt(in.next());
            } byte i = 0; byte 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 += 2) {
                Alice += a[i];
            } int i = 0; int i = 0; i 0 i < N i N i += 2 i += 2 i 2 {
                Alice += a[i];
            } {
                Alice += a[i];
            } Alice += a[i] Alice a[i] a i for (int i = 1; i < N; i += 2) {
                Bob += a[i];
            } int i = 1; int i = 1; i 1 i < N i N i += 2 i += 2 i 2 {
                Bob += a[i];
            } {
                Bob += a[i];
            } Bob += a[i] Bob a[i] a i out.println(Alice - Bob) out.println out Alice - Bob Alice Bob 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = Integer.parseInt(in.next());
            Integer a[] = new Integer[N];
            for (byte 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 += 2) {
                Alice += a[i];
            }
            for (int i = 1; i < N; i += 2) {
                Bob += a[i];
            }
            out.println(Alice - Bob);
        }

    }
} 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = Integer.parseInt(in.next());
            Integer a[] = new Integer[N];
            for (byte 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 += 2) {
                Alice += a[i];
            }
            for (int i = 1; i < N; i += 2) {
                Bob += a[i];
            }
            out.println(Alice - Bob);
        }

    }
} 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = Integer.parseInt(in.next());
            Integer a[] = new Integer[N];
            for (byte 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 += 2) {
                Alice += a[i];
            }
            for (int i = 1; i < N; i += 2) {
                Bob += a[i];
            }
            out.println(Alice - Bob);
        }

    }
}

