import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String[] s = stdR.readLine().split(" ");
        int[] a = new int[N];
        for(int i = 0 ; i < N ; i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        Arrays.sort(a);
        int alice = 0;
        int bob = 0;
        int count = 0;
        for(int i = N - 1 ; i >= 0 ; i--) {
            if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            }
            count++;
        }
        System.out.println(alice - bob);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String[] s = stdR.readLine().split(" ");
        int[] a = new int[N];
        for(int i = 0 ; i < N ; i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        Arrays.sort(a);
        int alice = 0;
        int bob = 0;
        int count = 0;
        for(int i = N - 1 ; i >= 0 ; i--) {
            if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            }
            count++;
        }
        System.out.println(alice - bob);
    }
} Main public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String[] s = stdR.readLine().split(" ");
        int[] a = new int[N];
        for(int i = 0 ; i < N ; i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        Arrays.sort(a);
        int alice = 0;
        int bob = 0;
        int count = 0;
        for(int i = N - 1 ; i >= 0 ; i--) {
            if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            }
            count++;
        }
        System.out.println(alice - bob);
    } main {
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String[] s = stdR.readLine().split(" ");
        int[] a = new int[N];
        for(int i = 0 ; i < N ; i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        Arrays.sort(a);
        int alice = 0;
        int bob = 0;
        int count = 0;
        for(int i = N - 1 ; i >= 0 ; i--) {
            if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            }
            count++;
        }
        System.out.println(alice - bob);
    } BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in)); stdR new BufferedReader(new InputStreamReader(System.in)) int N = Integer.parseInt(stdR.readLine()); N Integer.parseInt(stdR.readLine()) Integer.parseInt Integer stdR.readLine() stdR.readLine stdR String[] s = stdR.readLine().split(" "); s stdR.readLine().split(" ") stdR.readLine().split stdR.readLine() stdR.readLine stdR " " int[] a = new int[N]; a new int[N] N for(int i = 0 ; i < N ; i++) {
            a[i] = Integer.parseInt(s[i]);
        } int i = 0 ; int i = 0 ; i 0 i < N i N i++ i++ i {
            a[i] = Integer.parseInt(s[i]);
        } {
            a[i] = Integer.parseInt(s[i]);
        } a[i] = Integer.parseInt(s[i]) a[i] a i Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i Arrays.sort(a) Arrays.sort Arrays a int alice = 0; alice 0 int bob = 0; bob 0 int count = 0; count 0 for(int i = N - 1 ; i >= 0 ; i--) {
            if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            }
            count++;
        } int i = N - 1 ; int i = N - 1 ; i N - 1 N 1 i >= 0 i 0 i-- i-- i {
            if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            }
            count++;
        } {
            if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            }
            count++;
        } if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            } count % 2 == 0 count % 2 count 2 0 {
                alice += a[i];
            } alice += a[i] alice a[i] a i {
                bob += a[i];
            } bob += a[i] bob a[i] a i count++ count 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{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String[] s = stdR.readLine().split(" ");
        int[] a = new int[N];
        for(int i = 0 ; i < N ; i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        Arrays.sort(a);
        int alice = 0;
        int bob = 0;
        int count = 0;
        for(int i = N - 1 ; i >= 0 ; i--) {
            if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            }
            count++;
        }
        System.out.println(alice - bob);
    }
} public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String[] s = stdR.readLine().split(" ");
        int[] a = new int[N];
        for(int i = 0 ; i < N ; i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        Arrays.sort(a);
        int alice = 0;
        int bob = 0;
        int count = 0;
        for(int i = N - 1 ; i >= 0 ; i--) {
            if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            }
            count++;
        }
        System.out.println(alice - bob);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String[] s = stdR.readLine().split(" ");
        int[] a = new int[N];
        for(int i = 0 ; i < N ; i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        Arrays.sort(a);
        int alice = 0;
        int bob = 0;
        int count = 0;
        for(int i = N - 1 ; i >= 0 ; i--) {
            if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            }
            count++;
        }
        System.out.println(alice - bob);
    }
}