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

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        Integer[] nums = new Integer[N];

        for (int i = 0; i < N ; i++) {
            nums[i] = scanner.nextInt();
        }

        int diff = 0;
        boolean isEven = (N % 2) == 0;

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

        int pairLastIndex = isEven ? N-1: N-2;
        for (int i = 0; i < pairLastIndex ; i = i+2) {
            diff += nums[i] - nums[i+1];
        }

        if (!isEven) diff += nums[N-1];

        System.out.println(diff);

    }
} 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 scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        Integer[] nums = new Integer[N];

        for (int i = 0; i < N ; i++) {
            nums[i] = scanner.nextInt();
        }

        int diff = 0;
        boolean isEven = (N % 2) == 0;

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

        int pairLastIndex = isEven ? N-1: N-2;
        for (int i = 0; i < pairLastIndex ; i = i+2) {
            diff += nums[i] - nums[i+1];
        }

        if (!isEven) diff += nums[N-1];

        System.out.println(diff);

    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        Integer[] nums = new Integer[N];

        for (int i = 0; i < N ; i++) {
            nums[i] = scanner.nextInt();
        }

        int diff = 0;
        boolean isEven = (N % 2) == 0;

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

        int pairLastIndex = isEven ? N-1: N-2;
        for (int i = 0; i < pairLastIndex ; i = i+2) {
            diff += nums[i] - nums[i+1];
        }

        if (!isEven) diff += nums[N-1];

        System.out.println(diff);

    } main {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        Integer[] nums = new Integer[N];

        for (int i = 0; i < N ; i++) {
            nums[i] = scanner.nextInt();
        }

        int diff = 0;
        boolean isEven = (N % 2) == 0;

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

        int pairLastIndex = isEven ? N-1: N-2;
        for (int i = 0; i < pairLastIndex ; i = i+2) {
            diff += nums[i] - nums[i+1];
        }

        if (!isEven) diff += nums[N-1];

        System.out.println(diff);

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner Integer[] nums = new Integer[N]; nums new Integer[N] N for (int i = 0; i < N ; i++) {
            nums[i] = scanner.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            nums[i] = scanner.nextInt();
        } {
            nums[i] = scanner.nextInt();
        } nums[i] = scanner.nextInt() nums[i] nums i scanner.nextInt() scanner.nextInt scanner int diff = 0; diff 0 boolean isEven = (N % 2) == 0; isEven (N % 2) == 0 (N % 2) N 2 0 Arrays.sort(nums, Collections.reverseOrder()) Arrays.sort Arrays nums Collections.reverseOrder() Collections.reverseOrder Collections int pairLastIndex = isEven ? N-1: N-2; pairLastIndex isEven ? N-1: N-2 isEven N-1 N 1 N-2 N 2 for (int i = 0; i < pairLastIndex ; i = i+2) {
            diff += nums[i] - nums[i+1];
        } int i = 0; int i = 0; i 0 i < pairLastIndex i pairLastIndex i = i+2 i = i+2 i i+2 i 2 {
            diff += nums[i] - nums[i+1];
        } {
            diff += nums[i] - nums[i+1];
        } diff += nums[i] - nums[i+1] diff nums[i] - nums[i+1] nums[i] nums i nums[i+1] nums i+1 i 1 if (!isEven) diff += nums[N-1]; !isEven isEven diff += nums[N-1] diff nums[N-1] nums N-1 N 1 System.out.println(diff) System.out.println System.out System System.out diff String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        Integer[] nums = new Integer[N];

        for (int i = 0; i < N ; i++) {
            nums[i] = scanner.nextInt();
        }

        int diff = 0;
        boolean isEven = (N % 2) == 0;

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

        int pairLastIndex = isEven ? N-1: N-2;
        for (int i = 0; i < pairLastIndex ; i = i+2) {
            diff += nums[i] - nums[i+1];
        }

        if (!isEven) diff += nums[N-1];

        System.out.println(diff);

    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        Integer[] nums = new Integer[N];

        for (int i = 0; i < N ; i++) {
            nums[i] = scanner.nextInt();
        }

        int diff = 0;
        boolean isEven = (N % 2) == 0;

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

        int pairLastIndex = isEven ? N-1: N-2;
        for (int i = 0; i < pairLastIndex ; i = i+2) {
            diff += nums[i] - nums[i+1];
        }

        if (!isEven) diff += nums[N-1];

        System.out.println(diff);

    }
} Main
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        Integer[] nums = new Integer[N];

        for (int i = 0; i < N ; i++) {
            nums[i] = scanner.nextInt();
        }

        int diff = 0;
        boolean isEven = (N % 2) == 0;

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

        int pairLastIndex = isEven ? N-1: N-2;
        for (int i = 0; i < pairLastIndex ; i = i+2) {
            diff += nums[i] - nums[i+1];
        }

        if (!isEven) diff += nums[N-1];

        System.out.println(diff);

    }
}