import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int n = Integer.valueOf(sc.next());
        Integer[] ai = new Integer[n];
        for(int i=0; i<n; i++){
            ai[i] = sc.nextInt();
        }
        Arrays.sort(ai ,Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for(int i=0; i < ai.length; i=i+2) {
            alice += ai[i];
        }
        for(int j=1; j< ai.length; j=j+2) {
            bob += ai[j];
        }
        System.out.println(alice - bob);
        sc.close();
    }       
} import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int n = Integer.valueOf(sc.next());
        Integer[] ai = new Integer[n];
        for(int i=0; i<n; i++){
            ai[i] = sc.nextInt();
        }
        Arrays.sort(ai ,Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for(int i=0; i < ai.length; i=i+2) {
            alice += ai[i];
        }
        for(int j=1; j< ai.length; j=j+2) {
            bob += ai[j];
        }
        System.out.println(alice - bob);
        sc.close();
    }       
} Main public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int n = Integer.valueOf(sc.next());
        Integer[] ai = new Integer[n];
        for(int i=0; i<n; i++){
            ai[i] = sc.nextInt();
        }
        Arrays.sort(ai ,Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for(int i=0; i < ai.length; i=i+2) {
            alice += ai[i];
        }
        for(int j=1; j< ai.length; j=j+2) {
            bob += ai[j];
        }
        System.out.println(alice - bob);
        sc.close();
    } main {
        final Scanner sc = new Scanner(System.in);
        final int n = Integer.valueOf(sc.next());
        Integer[] ai = new Integer[n];
        for(int i=0; i<n; i++){
            ai[i] = sc.nextInt();
        }
        Arrays.sort(ai ,Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for(int i=0; i < ai.length; i=i+2) {
            alice += ai[i];
        }
        for(int j=1; j< ai.length; j=j+2) {
            bob += ai[j];
        }
        System.out.println(alice - bob);
        sc.close();
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int n = Integer.valueOf(sc.next()); n Integer.valueOf(sc.next()) Integer.valueOf Integer sc.next() sc.next sc Integer[] ai = new Integer[n]; ai new Integer[n] n for(int i=0; i<n; i++){
            ai[i] = sc.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            ai[i] = sc.nextInt();
        } {
            ai[i] = sc.nextInt();
        } ai[i] = sc.nextInt() ai[i] ai i sc.nextInt() sc.nextInt sc Arrays.sort(ai ,Comparator.reverseOrder()) Arrays.sort Arrays ai Comparator.reverseOrder() Comparator.reverseOrder Comparator int alice = 0; alice 0 int bob = 0; bob 0 for(int i=0; i < ai.length; i=i+2) {
            alice += ai[i];
        } int i=0; int i=0; i 0 i < ai.length i ai.length ai ai.length i=i+2 i=i+2 i i+2 i 2 {
            alice += ai[i];
        } {
            alice += ai[i];
        } alice += ai[i] alice ai[i] ai i for(int j=1; j< ai.length; j=j+2) {
            bob += ai[j];
        } int j=1; int j=1; j 1 j< ai.length j ai.length ai ai.length j=j+2 j=j+2 j j+2 j 2 {
            bob += ai[j];
        } {
            bob += ai[j];
        } bob += ai[j] bob ai[j] ai j System.out.println(alice - bob) System.out.println System.out System System.out alice - bob alice bob sc.close() sc.close sc final String[] args args public class Main {

    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int n = Integer.valueOf(sc.next());
        Integer[] ai = new Integer[n];
        for(int i=0; i<n; i++){
            ai[i] = sc.nextInt();
        }
        Arrays.sort(ai ,Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for(int i=0; i < ai.length; i=i+2) {
            alice += ai[i];
        }
        for(int j=1; j< ai.length; j=j+2) {
            bob += ai[j];
        }
        System.out.println(alice - bob);
        sc.close();
    }       
} public class Main {

    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int n = Integer.valueOf(sc.next());
        Integer[] ai = new Integer[n];
        for(int i=0; i<n; i++){
            ai[i] = sc.nextInt();
        }
        Arrays.sort(ai ,Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for(int i=0; i < ai.length; i=i+2) {
            alice += ai[i];
        }
        for(int j=1; j< ai.length; j=j+2) {
            bob += ai[j];
        }
        System.out.println(alice - bob);
        sc.close();
    }       
} Main
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int n = Integer.valueOf(sc.next());
        Integer[] ai = new Integer[n];
        for(int i=0; i<n; i++){
            ai[i] = sc.nextInt();
        }
        Arrays.sort(ai ,Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        for(int i=0; i < ai.length; i=i+2) {
            alice += ai[i];
        }
        for(int j=1; j< ai.length; j=j+2) {
            bob += ai[j];
        }
        System.out.println(alice - bob);
        sc.close();
    }       
}