//package Contest088;

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n  = sc.nextInt();
            int arr[] = new int[n];
            for(int i=0;i<n;i++)
                arr[i] = sc.nextInt();
            Arrays.sort(arr);
            int alice=0,bob =0;
            for(int i=arr.length-1;i>=0;i--)
            {
                if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i];
            }
            if(alice>bob)
                out.println(alice-bob);
            else
                out.println(bob-alice);
        out.flush();
    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n  = sc.nextInt();
            int arr[] = new int[n];
            for(int i=0;i<n;i++)
                arr[i] = sc.nextInt();
            Arrays.sort(arr);
            int alice=0,bob =0;
            for(int i=arr.length-1;i>=0;i--)
            {
                if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i];
            }
            if(alice>bob)
                out.println(alice-bob);
            else
                out.println(bob-alice);
        out.flush();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n  = sc.nextInt();
            int arr[] = new int[n];
            for(int i=0;i<n;i++)
                arr[i] = sc.nextInt();
            Arrays.sort(arr);
            int alice=0,bob =0;
            for(int i=arr.length-1;i>=0;i--)
            {
                if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i];
            }
            if(alice>bob)
                out.println(alice-bob);
            else
                out.println(bob-alice);
        out.flush();
    } main {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n  = sc.nextInt();
            int arr[] = new int[n];
            for(int i=0;i<n;i++)
                arr[i] = sc.nextInt();
            Arrays.sort(arr);
            int alice=0,bob =0;
            for(int i=arr.length-1;i>=0;i--)
            {
                if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i];
            }
            if(alice>bob)
                out.println(alice-bob);
            else
                out.println(bob-alice);
        out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int n  = sc.nextInt(); n sc.nextInt() sc.nextInt sc int arr[] = new int[n]; arr new int[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] arr i sc.nextInt() sc.nextInt sc Arrays.sort(arr) Arrays.sort Arrays arr int alice=0 alice 0 bob =0; bob 0 for(int i=arr.length-1;i>=0;i--)
            {
                if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i];
            } int i=arr.length-1; int i=arr.length-1; i arr.length-1 arr.length arr arr.length 1 i>=0 i 0 i-- i-- i {
                if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i];
            } {
                if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i];
            } if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i]; i%2==0 i%2 i 2 0 alice+=arr[i] alice arr[i] arr i bob+=arr[i] bob arr[i] arr i if(alice>bob)
                out.println(alice-bob);
            else
                out.println(bob-alice); alice>bob alice bob out.println(alice-bob) out.println out alice-bob alice bob out.println(bob-alice) out.println out bob-alice bob alice out.flush() out.flush out String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n  = sc.nextInt();
            int arr[] = new int[n];
            for(int i=0;i<n;i++)
                arr[i] = sc.nextInt();
            Arrays.sort(arr);
            int alice=0,bob =0;
            for(int i=arr.length-1;i>=0;i--)
            {
                if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i];
            }
            if(alice>bob)
                out.println(alice-bob);
            else
                out.println(bob-alice);
        out.flush();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n  = sc.nextInt();
            int arr[] = new int[n];
            for(int i=0;i<n;i++)
                arr[i] = sc.nextInt();
            Arrays.sort(arr);
            int alice=0,bob =0;
            for(int i=arr.length-1;i>=0;i--)
            {
                if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i];
            }
            if(alice>bob)
                out.println(alice-bob);
            else
                out.println(bob-alice);
        out.flush();
    }
} Main
//package Contest088;

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n  = sc.nextInt();
            int arr[] = new int[n];
            for(int i=0;i<n;i++)
                arr[i] = sc.nextInt();
            Arrays.sort(arr);
            int alice=0,bob =0;
            for(int i=arr.length-1;i>=0;i--)
            {
                if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i];
            }
            if(alice>bob)
                out.println(alice-bob);
            else
                out.println(bob-alice);
        out.flush();
    }
}
