import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];

        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        int tmp;
        for (int i = 0; i < N-1; i++) {
            for (int j = 0; j < N - i - 1; j++) {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            }
        }

        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < N; i++) {
            if (i%2 == 0) {
                aliceSum += a[i];
            } else {
                bobSum += a[i];
            }
        }
        System.out.println(aliceSum - bobSum);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];

        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        int tmp;
        for (int i = 0; i < N-1; i++) {
            for (int j = 0; j < N - i - 1; j++) {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            }
        }

        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < N; i++) {
            if (i%2 == 0) {
                aliceSum += a[i];
            } else {
                bobSum += a[i];
            }
        }
        System.out.println(aliceSum - bobSum);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];

        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        int tmp;
        for (int i = 0; i < N-1; i++) {
            for (int j = 0; j < N - i - 1; j++) {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            }
        }

        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < N; i++) {
            if (i%2 == 0) {
                aliceSum += a[i];
            } else {
                bobSum += a[i];
            }
        }
        System.out.println(aliceSum - bobSum);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];

        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        int tmp;
        for (int i = 0; i < N-1; i++) {
            for (int j = 0; j < N - i - 1; j++) {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            }
        }

        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < N; i++) {
            if (i%2 == 0) {
                aliceSum += a[i];
            } else {
                bobSum += a[i];
            }
        }
        System.out.println(aliceSum - bobSum);
    } 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 int[] a = new int[N]; a new int[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 int tmp; tmp for (int i = 0; i < N-1; i++) {
            for (int j = 0; j < N - i - 1; j++) {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            }
        } int i = 0; int i = 0; i 0 i < N-1 i N-1 N 1 i++ i++ i {
            for (int j = 0; j < N - i - 1; j++) {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            }
        } {
            for (int j = 0; j < N - i - 1; j++) {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            }
        } for (int j = 0; j < N - i - 1; j++) {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            } int j = 0; int j = 0; j 0 j < N - i - 1 j N - i - 1 N - i - 1 N i 1 j++ j++ j {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            } {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            } if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                } a[j] < a[j+1] a[j] a j a[j+1] a j+1 j 1 {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                } tmp = a[j+1] tmp a[j+1] a j+1 j 1 a[j+1] = a[j] a[j+1] a j+1 j 1 a[j] a j a[j] = tmp a[j] a j tmp int aliceSum = 0; aliceSum 0 int bobSum = 0; bobSum 0 for (int i = 0; i < N; i++) {
            if (i%2 == 0) {
                aliceSum += a[i];
            } else {
                bobSum += a[i];
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if (i%2 == 0) {
                aliceSum += a[i];
            } else {
                bobSum += a[i];
            }
        } {
            if (i%2 == 0) {
                aliceSum += a[i];
            } else {
                bobSum += a[i];
            }
        } if (i%2 == 0) {
                aliceSum += a[i];
            } else {
                bobSum += a[i];
            } i%2 == 0 i%2 i 2 0 {
                aliceSum += a[i];
            } aliceSum += a[i] aliceSum a[i] a i {
                bobSum += a[i];
            } bobSum += a[i] bobSum a[i] a i System.out.println(aliceSum - bobSum) System.out.println System.out System System.out aliceSum - bobSum aliceSum bobSum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];

        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        int tmp;
        for (int i = 0; i < N-1; i++) {
            for (int j = 0; j < N - i - 1; j++) {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            }
        }

        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < N; i++) {
            if (i%2 == 0) {
                aliceSum += a[i];
            } else {
                bobSum += a[i];
            }
        }
        System.out.println(aliceSum - bobSum);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];

        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        int tmp;
        for (int i = 0; i < N-1; i++) {
            for (int j = 0; j < N - i - 1; j++) {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            }
        }

        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < N; i++) {
            if (i%2 == 0) {
                aliceSum += a[i];
            } else {
                bobSum += a[i];
            }
        }
        System.out.println(aliceSum - bobSum);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];

        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        int tmp;
        for (int i = 0; i < N-1; i++) {
            for (int j = 0; j < N - i - 1; j++) {
                if ( a[j] < a[j+1] ) {
                    tmp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = tmp;
                }
            }
        }

        int aliceSum = 0;
        int bobSum = 0;
        for (int i = 0; i < N; i++) {
            if (i%2 == 0) {
                aliceSum += a[i];
            } else {
                bobSum += a[i];
            }
        }
        System.out.println(aliceSum - bobSum);
    }
}
