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());
        }
        Arrays.sort(A,Comparator.reverseOrder());
        int Alice=0;
        int Bob  =0;
        for (int i=0;i<n;i+=2){
            Alice+=A[i];
        }
        for (int i=1;i<n;i+=2){
            Bob+=A[i];
        }
        System.out.println(Alice-Bob);
    }
} 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());
        }
        Arrays.sort(A,Comparator.reverseOrder());
        int Alice=0;
        int Bob  =0;
        for (int i=0;i<n;i+=2){
            Alice+=A[i];
        }
        for (int i=1;i<n;i+=2){
            Bob+=A[i];
        }
        System.out.println(Alice-Bob);
    }
} 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());
        }
        Arrays.sort(A,Comparator.reverseOrder());
        int Alice=0;
        int Bob  =0;
        for (int i=0;i<n;i+=2){
            Alice+=A[i];
        }
        for (int i=1;i<n;i+=2){
            Bob+=A[i];
        }
        System.out.println(Alice-Bob);
    } 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());
        }
        Arrays.sort(A,Comparator.reverseOrder());
        int Alice=0;
        int Bob  =0;
        for (int i=0;i<n;i+=2){
            Alice+=A[i];
        }
        for (int i=1;i<n;i+=2){
            Bob+=A[i];
        }
        System.out.println(Alice-Bob);
    } 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 Arrays.sort(A,Comparator.reverseOrder()) Arrays.sort Arrays A Comparator.reverseOrder() Comparator.reverseOrder Comparator int Alice=0; Alice 0 int Bob  =0; Bob 0 for (int i=0;i<n;i+=2){
            Alice+=A[i];
        } int i=0; int i=0; i 0 i<n i n i+=2 i+=2 i 2 {
            Alice+=A[i];
        } {
            Alice+=A[i];
        } Alice+=A[i] Alice A[i] A i for (int i=1;i<n;i+=2){
            Bob+=A[i];
        } int i=1; int i=1; i 1 i<n i n i+=2 i+=2 i 2 {
            Bob+=A[i];
        } {
            Bob+=A[i];
        } Bob+=A[i] Bob A[i] A i System.out.println(Alice-Bob) System.out.println System.out System System.out Alice-Bob Alice Bob String[] args args
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());
        }
        Arrays.sort(A,Comparator.reverseOrder());
        int Alice=0;
        int Bob  =0;
        for (int i=0;i<n;i+=2){
            Alice+=A[i];
        }
        for (int i=1;i<n;i+=2){
            Bob+=A[i];
        }
        System.out.println(Alice-Bob);
    }
}