import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
    private static InputStream debugInput() {
        String s = "4\n" +
                "20 18 2 18";
        return new ByteArrayInputStream(s.getBytes());
    }

    private static InputStream stdin() {
        return System.in;
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(stdin());
        int n = sc.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }
        Arrays.sort(xs);

        boolean isA = true;
        int sumOfA = 0;
        int sumOfB = 0;
        for (int i = 0; i < n; i++) {
            int value = xs[n - i - 1];
            if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            }
            isA = !isA;
        }

        System.out.println(sumOfA - sumOfB);
   }
} import java.io.ByteArrayInputStream; ByteArrayInputStream java.io import java.io.InputStream; InputStream java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main
{
    private static InputStream debugInput() {
        String s = "4\n" +
                "20 18 2 18";
        return new ByteArrayInputStream(s.getBytes());
    }

    private static InputStream stdin() {
        return System.in;
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(stdin());
        int n = sc.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }
        Arrays.sort(xs);

        boolean isA = true;
        int sumOfA = 0;
        int sumOfB = 0;
        for (int i = 0; i < n; i++) {
            int value = xs[n - i - 1];
            if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            }
            isA = !isA;
        }

        System.out.println(sumOfA - sumOfB);
   }
} Main private static InputStream debugInput() {
        String s = "4\n" +
                "20 18 2 18";
        return new ByteArrayInputStream(s.getBytes());
    } debugInput {
        String s = "4\n" +
                "20 18 2 18";
        return new ByteArrayInputStream(s.getBytes());
    } String s = "4\n" +
                "20 18 2 18"; s "4\n" +
                "20 18 2 18" "4\n" "20 18 2 18" return new ByteArrayInputStream(s.getBytes()); new ByteArrayInputStream(s.getBytes()) private static InputStream stdin() {
        return System.in;
    } stdin {
        return System.in;
    } return System.in; System.in System System.in public static void main(String[] args)
    {
        Scanner sc = new Scanner(stdin());
        int n = sc.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }
        Arrays.sort(xs);

        boolean isA = true;
        int sumOfA = 0;
        int sumOfB = 0;
        for (int i = 0; i < n; i++) {
            int value = xs[n - i - 1];
            if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            }
            isA = !isA;
        }

        System.out.println(sumOfA - sumOfB);
   } main {
        Scanner sc = new Scanner(stdin());
        int n = sc.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }
        Arrays.sort(xs);

        boolean isA = true;
        int sumOfA = 0;
        int sumOfB = 0;
        for (int i = 0; i < n; i++) {
            int value = xs[n - i - 1];
            if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            }
            isA = !isA;
        }

        System.out.println(sumOfA - sumOfB);
   } Scanner sc = new Scanner(stdin()); sc new Scanner(stdin()) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] xs = new int[n]; xs new int[n] n for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            xs[i] = sc.nextInt();
        } {
            xs[i] = sc.nextInt();
        } xs[i] = sc.nextInt() xs[i] xs i sc.nextInt() sc.nextInt sc Arrays.sort(xs) Arrays.sort Arrays xs boolean isA = true; isA true int sumOfA = 0; sumOfA 0 int sumOfB = 0; sumOfB 0 for (int i = 0; i < n; i++) {
            int value = xs[n - i - 1];
            if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            }
            isA = !isA;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int value = xs[n - i - 1];
            if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            }
            isA = !isA;
        } {
            int value = xs[n - i - 1];
            if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            }
            isA = !isA;
        } int value = xs[n - i - 1]; value xs[n - i - 1] xs n - i - 1 n - i - 1 n i 1 if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            } isA {
                sumOfA += value;
            } sumOfA += value sumOfA value {
                sumOfB += value;
            } sumOfB += value sumOfB value isA = !isA isA !isA isA System.out.println(sumOfA - sumOfB) System.out.println System.out System System.out sumOfA - sumOfB sumOfA sumOfB String[] args args public class Main
{
    private static InputStream debugInput() {
        String s = "4\n" +
                "20 18 2 18";
        return new ByteArrayInputStream(s.getBytes());
    }

    private static InputStream stdin() {
        return System.in;
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(stdin());
        int n = sc.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }
        Arrays.sort(xs);

        boolean isA = true;
        int sumOfA = 0;
        int sumOfB = 0;
        for (int i = 0; i < n; i++) {
            int value = xs[n - i - 1];
            if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            }
            isA = !isA;
        }

        System.out.println(sumOfA - sumOfB);
   }
} public class Main
{
    private static InputStream debugInput() {
        String s = "4\n" +
                "20 18 2 18";
        return new ByteArrayInputStream(s.getBytes());
    }

    private static InputStream stdin() {
        return System.in;
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(stdin());
        int n = sc.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }
        Arrays.sort(xs);

        boolean isA = true;
        int sumOfA = 0;
        int sumOfB = 0;
        for (int i = 0; i < n; i++) {
            int value = xs[n - i - 1];
            if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            }
            isA = !isA;
        }

        System.out.println(sumOfA - sumOfB);
   }
} Main
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
    private static InputStream debugInput() {
        String s = "4\n" +
                "20 18 2 18";
        return new ByteArrayInputStream(s.getBytes());
    }

    private static InputStream stdin() {
        return System.in;
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(stdin());
        int n = sc.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }
        Arrays.sort(xs);

        boolean isA = true;
        int sumOfA = 0;
        int sumOfB = 0;
        for (int i = 0; i < n; i++) {
            int value = xs[n - i - 1];
            if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            }
            isA = !isA;
        }

        System.out.println(sumOfA - sumOfB);
   }
}
