import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        int aliceSum = 0;
        int bobSum = 0;
        boolean isAliceTurn = true;
        for (int i = nums.length - 1; i >= 0; i--) {
            if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            }
        }
        System.out.println(aliceSum - bobSum);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        int aliceSum = 0;
        int bobSum = 0;
        boolean isAliceTurn = true;
        for (int i = nums.length - 1; i >= 0; i--) {
            if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            }
        }
        System.out.println(aliceSum - bobSum);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        int aliceSum = 0;
        int bobSum = 0;
        boolean isAliceTurn = true;
        for (int i = nums.length - 1; i >= 0; i--) {
            if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            }
        }
        System.out.println(aliceSum - bobSum);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        int aliceSum = 0;
        int bobSum = 0;
        boolean isAliceTurn = true;
        for (int i = nums.length - 1; i >= 0; i--) {
            if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            }
        }
        System.out.println(aliceSum - bobSum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] nums = new int[n]; nums new int[n] n for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            nums[i] = sc.nextInt();
        } {
            nums[i] = sc.nextInt();
        } nums[i] = sc.nextInt() nums[i] nums i sc.nextInt() sc.nextInt sc Arrays.sort(nums) Arrays.sort Arrays nums int aliceSum = 0; aliceSum 0 int bobSum = 0; bobSum 0 boolean isAliceTurn = true; isAliceTurn true for (int i = nums.length - 1; i >= 0; i--) {
            if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            }
        } int i = nums.length - 1; int i = nums.length - 1; i nums.length - 1 nums.length nums nums.length 1 i >= 0 i 0 i-- i-- i {
            if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            }
        } {
            if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            }
        } if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            } isAliceTurn {
                aliceSum += nums[i];
                isAliceTurn = false;
            } aliceSum += nums[i] aliceSum nums[i] nums i isAliceTurn = false isAliceTurn false {
                bobSum += nums[i];
                isAliceTurn = true;
            } bobSum += nums[i] bobSum nums[i] nums i isAliceTurn = true isAliceTurn true System.out.println(aliceSum - bobSum) System.out.println System.out System System.out aliceSum - bobSum aliceSum bobSum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        int aliceSum = 0;
        int bobSum = 0;
        boolean isAliceTurn = true;
        for (int i = nums.length - 1; i >= 0; i--) {
            if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            }
        }
        System.out.println(aliceSum - bobSum);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        int aliceSum = 0;
        int bobSum = 0;
        boolean isAliceTurn = true;
        for (int i = nums.length - 1; i >= 0; i--) {
            if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            }
        }
        System.out.println(aliceSum - bobSum);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        int aliceSum = 0;
        int bobSum = 0;
        boolean isAliceTurn = true;
        for (int i = nums.length - 1; i >= 0; i--) {
            if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            }
        }
        System.out.println(aliceSum - bobSum);
    }
}