import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N / 2; i++) {
            alice += a[2*i];
            bob += a[2*i + 1];
        }
        if (N % 2 == 1) {
            alice += a[N-1];
        }
        System.out.println(alice - bob);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io 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) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N / 2; i++) {
            alice += a[2*i];
            bob += a[2*i + 1];
        }
        if (N % 2 == 1) {
            alice += a[N-1];
        }
        System.out.println(alice - bob);
    }
} Main public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    } main {
        Main main = new Main();
        main.solve();
    } Main main = new Main(); main new Main() main.solve() main.solve main String[] args args public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N / 2; i++) {
            alice += a[2*i];
            bob += a[2*i + 1];
        }
        if (N % 2 == 1) {
            alice += a[N-1];
        }
        System.out.println(alice - bob);
    } solve {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N / 2; i++) {
            alice += a[2*i];
            bob += a[2*i + 1];
        }
        if (N % 2 == 1) {
            alice += a[N-1];
        }
        System.out.println(alice - bob);
    } Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in))); scan new Scanner(new BufferedReader(new InputStreamReader(System.in))) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan Integer[] a = new Integer[N]; a new Integer[N] N for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            a[i] = scan.nextInt();
        } {
            a[i] = scan.nextInt();
        } a[i] = scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan 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 / 2; i++) {
            alice += a[2*i];
            bob += a[2*i + 1];
        } int i = 0; int i = 0; i 0 i < N / 2 i N / 2 N 2 i++ i++ i {
            alice += a[2*i];
            bob += a[2*i + 1];
        } {
            alice += a[2*i];
            bob += a[2*i + 1];
        } alice += a[2*i] alice a[2*i] a 2*i 2 i bob += a[2*i + 1] bob a[2*i + 1] a 2*i + 1 2*i 2 i 1 if (N % 2 == 1) {
            alice += a[N-1];
        } N % 2 == 1 N % 2 N 2 1 {
            alice += a[N-1];
        } alice += a[N-1] alice a[N-1] a N-1 N 1 System.out.println(alice - bob) System.out.println System.out System System.out alice - bob alice bob public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N / 2; i++) {
            alice += a[2*i];
            bob += a[2*i + 1];
        }
        if (N % 2 == 1) {
            alice += a[N-1];
        }
        System.out.println(alice - bob);
    }
} public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N / 2; i++) {
            alice += a[2*i];
            bob += a[2*i + 1];
        }
        if (N % 2 == 1) {
            alice += a[N-1];
        }
        System.out.println(alice - bob);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for (int i = 0; i < N / 2; i++) {
            alice += a[2*i];
            bob += a[2*i + 1];
        }
        if (N % 2 == 1) {
            alice += a[N-1];
        }
        System.out.println(alice - bob);
    }
}
