import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] nums = new Integer[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums, Collections.reverseOrder());
        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                aliceSum += nums[i];
            } else {
                bobSum += nums[i];
            }
        }
        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();
        Integer[] nums = new Integer[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums, Collections.reverseOrder());
        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                aliceSum += nums[i];
            } else {
                bobSum += nums[i];
            }
        }
        System.out.println(aliceSum - bobSum);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] nums = new Integer[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums, Collections.reverseOrder());
        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                aliceSum += nums[i];
            } else {
                bobSum += nums[i];
            }
        }
        System.out.println(aliceSum - bobSum);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] nums = new Integer[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums, Collections.reverseOrder());
        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                aliceSum += nums[i];
            } else {
                bobSum += nums[i];
            }
        }
        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 Integer[] nums = new Integer[n]; nums new Integer[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, Collections.reverseOrder()) Arrays.sort Arrays nums Collections.reverseOrder() Collections.reverseOrder Collections int aliceSum = 0; aliceSum 0 int bobSum = 0; bobSum 0 for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                aliceSum += nums[i];
            } else {
                bobSum += nums[i];
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if (i % 2 == 0) {
                aliceSum += nums[i];
            } else {
                bobSum += nums[i];
            }
        } {
            if (i % 2 == 0) {
                aliceSum += nums[i];
            } else {
                bobSum += nums[i];
            }
        } if (i % 2 == 0) {
                aliceSum += nums[i];
            } else {
                bobSum += nums[i];
            } i % 2 == 0 i % 2 i 2 0 {
                aliceSum += nums[i];
            } aliceSum += nums[i] aliceSum nums[i] nums i {
                bobSum += nums[i];
            } bobSum += nums[i] bobSum nums[i] nums i 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();
        Integer[] nums = new Integer[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums, Collections.reverseOrder());
        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                aliceSum += nums[i];
            } else {
                bobSum += nums[i];
            }
        }
        System.out.println(aliceSum - bobSum);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] nums = new Integer[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums, Collections.reverseOrder());
        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                aliceSum += nums[i];
            } else {
                bobSum += nums[i];
            }
        }
        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();
        Integer[] nums = new Integer[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums, Collections.reverseOrder());
        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                aliceSum += nums[i];
            } else {
                bobSum += nums[i];
            }
        }
        System.out.println(aliceSum - bobSum);
    }
}