import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer arr[] = new Integer[n];

        for (int i = 0; i < n; ++i) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i+=2) {
            alice += arr[i];
        }
        for (int i = 1; i < n; i+=2) {
            bob += arr[i];
        }

        System.out.println(alice - bob);



    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer arr[] = new Integer[n];

        for (int i = 0; i < n; ++i) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i+=2) {
            alice += arr[i];
        }
        for (int i = 1; i < n; i+=2) {
            bob += arr[i];
        }

        System.out.println(alice - bob);



    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer arr[] = new Integer[n];

        for (int i = 0; i < n; ++i) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i+=2) {
            alice += arr[i];
        }
        for (int i = 1; i < n; i+=2) {
            bob += arr[i];
        }

        System.out.println(alice - bob);



    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer arr[] = new Integer[n];

        for (int i = 0; i < n; ++i) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i+=2) {
            alice += arr[i];
        }
        for (int i = 1; i < n; i+=2) {
            bob += arr[i];
        }

        System.out.println(alice - bob);



    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Integer arr[] = new Integer[n]; arr new Integer[n] n for (int i = 0; i < n; ++i) {
            arr[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            arr[i] = sc.nextInt();
        } {
            arr[i] = sc.nextInt();
        } arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc Arrays.sort(arr, Comparator.reverseOrder()) Arrays.sort Arrays arr Comparator.reverseOrder() Comparator.reverseOrder Comparator int alice = 0; alice 0 int bob = 0; bob 0 for (int i = 0; i < n; i+=2) {
            alice += arr[i];
        } int i = 0; int i = 0; i 0 i < n i n i+=2 i+=2 i 2 {
            alice += arr[i];
        } {
            alice += arr[i];
        } alice += arr[i] alice arr[i] arr i for (int i = 1; i < n; i+=2) {
            bob += arr[i];
        } int i = 1; int i = 1; i 1 i < n i n i+=2 i+=2 i 2 {
            bob += arr[i];
        } {
            bob += arr[i];
        } bob += arr[i] bob arr[i] arr i 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) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer arr[] = new Integer[n];

        for (int i = 0; i < n; ++i) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i+=2) {
            alice += arr[i];
        }
        for (int i = 1; i < n; i+=2) {
            bob += arr[i];
        }

        System.out.println(alice - bob);



    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer arr[] = new Integer[n];

        for (int i = 0; i < n; ++i) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i+=2) {
            alice += arr[i];
        }
        for (int i = 1; i < n; i+=2) {
            bob += arr[i];
        }

        System.out.println(alice - bob);



    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer arr[] = new Integer[n];

        for (int i = 0; i < n; ++i) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i+=2) {
            alice += arr[i];
        }
        for (int i = 1; i < n; i+=2) {
            bob += arr[i];
        }

        System.out.println(alice - bob);



    }
}