import java.util.*;

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