import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer a[] = new Integer[N];
        for (int i=0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(a, Comparator.reverseOrder());

        player Alice = new player("Alice", 0);
        player Bob = new player("Bob", 0);
        for (int i=0; i<N; i+=2) {
            Alice.addSum(a[i]);
        }
        for (int i=1; i<N; i+=2) {
            Bob.addSum(a[i]);
        }
        System.out.println(Alice.getSum() - Bob.getSum());
    }
}

class player {
    private String name;
    private int sum;

    public player(String name, int sum) {
        this.name = name;
        this.sum = sum;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void addSum(int sum) {
        this.sum += sum;
    }

    public int getSum() {
        return this.sum;
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer a[] = new Integer[N];
        for (int i=0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(a, Comparator.reverseOrder());

        player Alice = new player("Alice", 0);
        player Bob = new player("Bob", 0);
        for (int i=0; i<N; i+=2) {
            Alice.addSum(a[i]);
        }
        for (int i=1; i<N; i+=2) {
            Bob.addSum(a[i]);
        }
        System.out.println(Alice.getSum() - Bob.getSum());
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer a[] = new Integer[N];
        for (int i=0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(a, Comparator.reverseOrder());

        player Alice = new player("Alice", 0);
        player Bob = new player("Bob", 0);
        for (int i=0; i<N; i+=2) {
            Alice.addSum(a[i]);
        }
        for (int i=1; i<N; i+=2) {
            Bob.addSum(a[i]);
        }
        System.out.println(Alice.getSum() - Bob.getSum());
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer a[] = new Integer[N];
        for (int i=0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(a, Comparator.reverseOrder());

        player Alice = new player("Alice", 0);
        player Bob = new player("Bob", 0);
        for (int i=0; i<N; i+=2) {
            Alice.addSum(a[i]);
        }
        for (int i=1; i<N; i+=2) {
            Bob.addSum(a[i]);
        }
        System.out.println(Alice.getSum() - Bob.getSum());
    } 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 Integer a[] = new Integer[N]; a new Integer[N] N for (int i=0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            a[i] = Integer.parseInt(sc.next());
        } {
            a[i] = Integer.parseInt(sc.next());
        } a[i] = Integer.parseInt(sc.next()) a[i] a i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc Arrays.sort(a, Comparator.reverseOrder()) Arrays.sort Arrays a Comparator.reverseOrder() Comparator.reverseOrder Comparator player Alice = new player("Alice", 0); Alice new player("Alice", 0) player Bob = new player("Bob", 0); Bob new player("Bob", 0) for (int i=0; i<N; i+=2) {
            Alice.addSum(a[i]);
        } int i=0; int i=0; i 0 i<N i N i+=2 i+=2 i 2 {
            Alice.addSum(a[i]);
        } {
            Alice.addSum(a[i]);
        } Alice.addSum(a[i]) Alice.addSum Alice a[i] a i for (int i=1; i<N; i+=2) {
            Bob.addSum(a[i]);
        } int i=1; int i=1; i 1 i<N i N i+=2 i+=2 i 2 {
            Bob.addSum(a[i]);
        } {
            Bob.addSum(a[i]);
        } Bob.addSum(a[i]) Bob.addSum Bob a[i] a i System.out.println(Alice.getSum() - Bob.getSum()) System.out.println System.out System System.out Alice.getSum() - Bob.getSum() Alice.getSum() Alice.getSum Alice Bob.getSum() Bob.getSum Bob String[] args args class player {
    private String name;
    private int sum;

    public player(String name, int sum) {
        this.name = name;
        this.sum = sum;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void addSum(int sum) {
        this.sum += sum;
    }

    public int getSum() {
        return this.sum;
    }
} player private String name; name private int sum; sum public player(String name, int sum) {
        this.name = name;
        this.sum = sum;
    } player {
        this.name = name;
        this.sum = sum;
    } this.name = name this.name this this.name name this.sum = sum this.sum this this.sum sum String name name int sum sum public void setName(String name) {
        this.name = name;
    } setName {
        this.name = name;
    } this.name = name this.name this this.name name String name name public void addSum(int sum) {
        this.sum += sum;
    } addSum {
        this.sum += sum;
    } this.sum += sum this.sum this this.sum sum int sum sum public int getSum() {
        return this.sum;
    } getSum {
        return this.sum;
    } return this.sum; this.sum this this.sum
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer a[] = new Integer[N];
        for (int i=0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(a, Comparator.reverseOrder());

        player Alice = new player("Alice", 0);
        player Bob = new player("Bob", 0);
        for (int i=0; i<N; i+=2) {
            Alice.addSum(a[i]);
        }
        for (int i=1; i<N; i+=2) {
            Bob.addSum(a[i]);
        }
        System.out.println(Alice.getSum() - Bob.getSum());
    }
}

class player {
    private String name;
    private int sum;

    public player(String name, int sum) {
        this.name = name;
        this.sum = sum;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void addSum(int sum) {
        this.sum += sum;
    }

    public int getSum() {
        return this.sum;
    }
}