import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer[] a = new Integer[N];
        int pA = 0;
        int pB = 0;
        int result = 0;
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(a, Collections.reverseOrder());

        // Aliceの点数
        for (int i = 0; i < N; i += 2) {
            pA += a[i];
            if (N > i + 1) {
                pB += a[i + 1];
            }
        }

        result = pA - pB;

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);

        sc.close();
        out.flush();
    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.Collections; Collections 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.next());
        Integer[] a = new Integer[N];
        int pA = 0;
        int pB = 0;
        int result = 0;
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(a, Collections.reverseOrder());

        // Aliceの点数
        for (int i = 0; i < N; i += 2) {
            pA += a[i];
            if (N > i + 1) {
                pB += a[i + 1];
            }
        }

        result = pA - pB;

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);

        sc.close();
        out.flush();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer[] a = new Integer[N];
        int pA = 0;
        int pB = 0;
        int result = 0;
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(a, Collections.reverseOrder());

        // Aliceの点数
        for (int i = 0; i < N; i += 2) {
            pA += a[i];
            if (N > i + 1) {
                pB += a[i + 1];
            }
        }

        result = pA - pB;

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);

        sc.close();
        out.flush();
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer[] a = new Integer[N];
        int pA = 0;
        int pB = 0;
        int result = 0;
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(a, Collections.reverseOrder());

        // Aliceの点数
        for (int i = 0; i < N; i += 2) {
            pA += a[i];
            if (N > i + 1) {
                pB += a[i + 1];
            }
        }

        result = pA - pB;

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);

        sc.close();
        out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Integer[] a = new Integer[N]; a new Integer[N] N int pA = 0; pA 0 int pB = 0; pB 0 int result = 0; result 0 for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            a[i] = Integer.parseInt(sc.next());
        } {
            a[i] = Integer.parseInt(sc.next());
        } a[i] = Integer.parseInt(sc.next()) a[i] a i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(a, Collections.reverseOrder()) Arrays.sort Arrays a Collections.reverseOrder() Collections.reverseOrder Collections for (int i = 0; i < N; i += 2) {
            pA += a[i];
            if (N > i + 1) {
                pB += a[i + 1];
            }
        } int i = 0; int i = 0; i 0 i < N i N i += 2 i += 2 i 2 {
            pA += a[i];
            if (N > i + 1) {
                pB += a[i + 1];
            }
        } {
            pA += a[i];
            if (N > i + 1) {
                pB += a[i + 1];
            }
        } pA += a[i] pA a[i] a i if (N > i + 1) {
                pB += a[i + 1];
            } N > i + 1 N i + 1 i 1 {
                pB += a[i + 1];
            } pB += a[i + 1] pB a[i + 1] a i + 1 i 1 result = pA - pB result pA - pB pA pB PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) out.println(result) out.println out result sc.close() sc.close sc out.flush() out.flush out String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer[] a = new Integer[N];
        int pA = 0;
        int pB = 0;
        int result = 0;
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(a, Collections.reverseOrder());

        // Aliceの点数
        for (int i = 0; i < N; i += 2) {
            pA += a[i];
            if (N > i + 1) {
                pB += a[i + 1];
            }
        }

        result = pA - pB;

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);

        sc.close();
        out.flush();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer[] a = new Integer[N];
        int pA = 0;
        int pB = 0;
        int result = 0;
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(a, Collections.reverseOrder());

        // Aliceの点数
        for (int i = 0; i < N; i += 2) {
            pA += a[i];
            if (N > i + 1) {
                pB += a[i + 1];
            }
        }

        result = pA - pB;

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);

        sc.close();
        out.flush();
    }
} Main
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer[] a = new Integer[N];
        int pA = 0;
        int pB = 0;
        int result = 0;
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(a, Collections.reverseOrder());

        // Aliceの点数
        for (int i = 0; i < N; i += 2) {
            pA += a[i];
            if (N > i + 1) {
                pB += a[i + 1];
            }
        }

        result = pA - pB;

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);

        sc.close();
        out.flush();
    }
}