import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        int alice =0;
        int Bob =0;
        for(int x=1;x<=n;x++) {
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list, Collections.reverseOrder());
        for(int x=1;x<=n;x++) {
            if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            }
        }
        System.out.println(alice-Bob);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        int alice =0;
        int Bob =0;
        for(int x=1;x<=n;x++) {
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list, Collections.reverseOrder());
        for(int x=1;x<=n;x++) {
            if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            }
        }
        System.out.println(alice-Bob);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        int alice =0;
        int Bob =0;
        for(int x=1;x<=n;x++) {
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list, Collections.reverseOrder());
        for(int x=1;x<=n;x++) {
            if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            }
        }
        System.out.println(alice-Bob);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        int alice =0;
        int Bob =0;
        for(int x=1;x<=n;x++) {
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list, Collections.reverseOrder());
        for(int x=1;x<=n;x++) {
            if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            }
        }
        System.out.println(alice-Bob);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc List<Integer> list = new ArrayList<>(); list new ArrayList<>() int alice =0; alice 0 int Bob =0; Bob 0 for(int x=1;x<=n;x++) {
            list.add(Integer.parseInt(sc.next()));
        } int x=1; int x=1; x 1 x<=n x n x++ x++ x {
            list.add(Integer.parseInt(sc.next()));
        } {
            list.add(Integer.parseInt(sc.next()));
        } list.add(Integer.parseInt(sc.next())) list.add list Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Collections.sort(list, Collections.reverseOrder()) Collections.sort Collections list Collections.reverseOrder() Collections.reverseOrder Collections for(int x=1;x<=n;x++) {
            if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            }
        } int x=1; int x=1; x 1 x<=n x n x++ x++ x {
            if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            }
        } {
            if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            }
        } if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            } x%2==1 x%2 x 2 1 {
                alice+=list.get(x-1);
            } alice+=list.get(x-1) alice list.get(x-1) list.get list x-1 x 1 {
                Bob+=list.get(x-1);
            } Bob+=list.get(x-1) Bob list.get(x-1) list.get list x-1 x 1 System.out.println(alice-Bob) System.out.println System.out System System.out alice-Bob alice Bob String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        int alice =0;
        int Bob =0;
        for(int x=1;x<=n;x++) {
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list, Collections.reverseOrder());
        for(int x=1;x<=n;x++) {
            if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            }
        }
        System.out.println(alice-Bob);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        int alice =0;
        int Bob =0;
        for(int x=1;x<=n;x++) {
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list, Collections.reverseOrder());
        for(int x=1;x<=n;x++) {
            if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            }
        }
        System.out.println(alice-Bob);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        int alice =0;
        int Bob =0;
        for(int x=1;x<=n;x++) {
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list, Collections.reverseOrder());
        for(int x=1;x<=n;x++) {
            if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            }
        }
        System.out.println(alice-Bob);
    }
}
