import java.util.*;

public class Main {
    public static void main(String[] args) {
        int ans=0;
        int bool = 1;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> nums = new LinkedList<>();
        for(int i=0;i<n;i++){
            nums.add(sc.nextInt());
        }
        nums.sort(Collections.reverseOrder());
        for (int num:nums){
            ans += num*bool;
            bool=(-bool);
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        int ans=0;
        int bool = 1;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> nums = new LinkedList<>();
        for(int i=0;i<n;i++){
            nums.add(sc.nextInt());
        }
        nums.sort(Collections.reverseOrder());
        for (int num:nums){
            ans += num*bool;
            bool=(-bool);
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        int ans=0;
        int bool = 1;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> nums = new LinkedList<>();
        for(int i=0;i<n;i++){
            nums.add(sc.nextInt());
        }
        nums.sort(Collections.reverseOrder());
        for (int num:nums){
            ans += num*bool;
            bool=(-bool);
        }
        System.out.println(ans);
    } main {
        int ans=0;
        int bool = 1;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> nums = new LinkedList<>();
        for(int i=0;i<n;i++){
            nums.add(sc.nextInt());
        }
        nums.sort(Collections.reverseOrder());
        for (int num:nums){
            ans += num*bool;
            bool=(-bool);
        }
        System.out.println(ans);
    } int ans=0; ans 0 int bool = 1; bool 1 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc LinkedList<Integer> nums = new LinkedList<>(); nums new LinkedList<>() for(int i=0;i<n;i++){
            nums.add(sc.nextInt());
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            nums.add(sc.nextInt());
        } {
            nums.add(sc.nextInt());
        } nums.add(sc.nextInt()) nums.add nums sc.nextInt() sc.nextInt sc nums.sort(Collections.reverseOrder()) nums.sort nums Collections.reverseOrder() Collections.reverseOrder Collections for (int num:nums){
            ans += num*bool;
            bool=(-bool);
        } int num nums {
            ans += num*bool;
            bool=(-bool);
        } {
            ans += num*bool;
            bool=(-bool);
        } ans += num*bool ans num*bool num bool bool=(-bool) bool (-bool) bool System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        int ans=0;
        int bool = 1;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> nums = new LinkedList<>();
        for(int i=0;i<n;i++){
            nums.add(sc.nextInt());
        }
        nums.sort(Collections.reverseOrder());
        for (int num:nums){
            ans += num*bool;
            bool=(-bool);
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        int ans=0;
        int bool = 1;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> nums = new LinkedList<>();
        for(int i=0;i<n;i++){
            nums.add(sc.nextInt());
        }
        nums.sort(Collections.reverseOrder());
        for (int num:nums){
            ans += num*bool;
            bool=(-bool);
        }
        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int ans=0;
        int bool = 1;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> nums = new LinkedList<>();
        for(int i=0;i<n;i++){
            nums.add(sc.nextInt());
        }
        nums.sort(Collections.reverseOrder());
        for (int num:nums){
            ans += num*bool;
            bool=(-bool);
        }
        System.out.println(ans);
    }
}