import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String[] args) {
        Scanner scn= new Scanner(System.in);
        int n=scn.nextInt();
        int[] a= new int[n];
        for(int i=0;i<n;i++){
            a[i]=scn.nextInt();
        }
        Arrays.sort(a);
        int alice=0;
        int bob=0;
        for(int i=0;i<n;i++){
            if(n%2==0){
                if(i%2==0){
                    bob+=a[i];
                }else{
                    alice+=a[i];
                }
            }else{
                if(i%2==0){
                    alice+=a[i];
                }else{
                    bob+=a[i];
                }
            }
        }
        System.out.println(alice-bob);
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util class Main{
    public static void main(String[] args) {
        Scanner scn= new Scanner(System.in);
        int n=scn.nextInt();
        int[] a= new int[n];
        for(int i=0;i<n;i++){
            a[i]=scn.nextInt();
        }
        Arrays.sort(a);
        int alice=0;
        int bob=0;
        for(int i=0;i<n;i++){
            if(n%2==0){
                if(i%2==0){
                    bob+=a[i];
                }else{
                    alice+=a[i];
                }
            }else{
                if(i%2==0){
                    alice+=a[i];
                }else{
                    bob+=a[i];
                }
            }
        }
        System.out.println(alice-bob);
    }
} Main public static void main(String[] args) {
        Scanner scn= new Scanner(System.in);
        int n=scn.nextInt();
        int[] a= new int[n];
        for(int i=0;i<n;i++){
            a[i]=scn.nextInt();
        }
        Arrays.sort(a);
        int alice=0;
        int bob=0;
        for(int i=0;i<n;i++){
            if(n%2==0){
                if(i%2==0){
                    bob+=a[i];
                }else{
                    alice+=a[i];
                }
            }else{
                if(i%2==0){
                    alice+=a[i];
                }else{
                    bob+=a[i];
                }
            }
        }
        System.out.println(alice-bob);
    } main {
        Scanner scn= new Scanner(System.in);
        int n=scn.nextInt();
        int[] a= new int[n];
        for(int i=0;i<n;i++){
            a[i]=scn.nextInt();
        }
        Arrays.sort(a);
        int alice=0;
        int bob=0;
        for(int i=0;i<n;i++){
            if(n%2==0){
                if(i%2==0){
                    bob+=a[i];
                }else{
                    alice+=a[i];
                }
            }else{
                if(i%2==0){
                    alice+=a[i];
                }else{
                    bob+=a[i];
                }
            }
        }
        System.out.println(alice-bob);
    } Scanner scn= new Scanner(System.in); scn new Scanner(System.in) int n=scn.nextInt(); n scn.nextInt() scn.nextInt scn int[] a= new int[n]; a new int[n] n for(int i=0;i<n;i++){
            a[i]=scn.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            a[i]=scn.nextInt();
        } {
            a[i]=scn.nextInt();
        } a[i]=scn.nextInt() a[i] a i scn.nextInt() scn.nextInt scn Arrays.sort(a) Arrays.sort Arrays a int alice=0; alice 0 int bob=0; bob 0 for(int i=0;i<n;i++){
            if(n%2==0){
                if(i%2==0){
                    bob+=a[i];
                }else{
                    alice+=a[i];
                }
            }else{
                if(i%2==0){
                    alice+=a[i];
                }else{
                    bob+=a[i];
                }
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            if(n%2==0){
                if(i%2==0){
                    bob+=a[i];
                }else{
                    alice+=a[i];
                }
            }else{
                if(i%2==0){
                    alice+=a[i];
                }else{
                    bob+=a[i];
                }
            }
        } {
            if(n%2==0){
                if(i%2==0){
                    bob+=a[i];
                }else{
                    alice+=a[i];
                }
            }else{
                if(i%2==0){
                    alice+=a[i];
                }else{
                    bob+=a[i];
                }
            }
        } if(n%2==0){
                if(i%2==0){
                    bob+=a[i];
                }else{
                    alice+=a[i];
                }
            }else{
                if(i%2==0){
                    alice+=a[i];
                }else{
                    bob+=a[i];
                }
            } n%2==0 n%2 n 2 0 {
                if(i%2==0){
                    bob+=a[i];
                }else{
                    alice+=a[i];
                }
            } if(i%2==0){
                    bob+=a[i];
                }else{
                    alice+=a[i];
                } i%2==0 i%2 i 2 0 {
                    bob+=a[i];
                } bob+=a[i] bob a[i] a i {
                    alice+=a[i];
                } alice+=a[i] alice a[i] a i {
                if(i%2==0){
                    alice+=a[i];
                }else{
                    bob+=a[i];
                }
            } if(i%2==0){
                    alice+=a[i];
                }else{
                    bob+=a[i];
                } i%2==0 i%2 i 2 0 {
                    alice+=a[i];
                } alice+=a[i] alice a[i] 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.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String[] args) {
        Scanner scn= new Scanner(System.in);
        int n=scn.nextInt();
        int[] a= new int[n];
        for(int i=0;i<n;i++){
            a[i]=scn.nextInt();
        }
        Arrays.sort(a);
        int alice=0;
        int bob=0;
        for(int i=0;i<n;i++){
            if(n%2==0){
                if(i%2==0){
                    bob+=a[i];
                }else{
                    alice+=a[i];
                }
            }else{
                if(i%2==0){
                    alice+=a[i];
                }else{
                    bob+=a[i];
                }
            }
        }
        System.out.println(alice-bob);
    }
}