import java.util.*;
import java.util.ArrayList;
public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Integer a[] = new Integer[N];
        boolean s = true;
        int Alice = 0;
        int Bob = 0;

        for(int i = 0;i < N;i++){
            a[i] = scanner.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());
        for(int i = 0;i < N;i++){
            if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
            s = !s;
        }

        System.out.println(Alice - Bob);
        }
} import java.util.*; util.* java import java.util.ArrayList; ArrayList java.util public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Integer a[] = new Integer[N];
        boolean s = true;
        int Alice = 0;
        int Bob = 0;

        for(int i = 0;i < N;i++){
            a[i] = scanner.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());
        for(int i = 0;i < N;i++){
            if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
            s = !s;
        }

        System.out.println(Alice - Bob);
        }
} Main public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Integer a[] = new Integer[N];
        boolean s = true;
        int Alice = 0;
        int Bob = 0;

        for(int i = 0;i < N;i++){
            a[i] = scanner.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());
        for(int i = 0;i < N;i++){
            if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
            s = !s;
        }

        System.out.println(Alice - Bob);
        } main {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Integer a[] = new Integer[N];
        boolean s = true;
        int Alice = 0;
        int Bob = 0;

        for(int i = 0;i < N;i++){
            a[i] = scanner.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());
        for(int i = 0;i < N;i++){
            if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
            s = !s;
        }

        System.out.println(Alice - Bob);
        } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner Integer a[] = new Integer[N]; a new Integer[N] N boolean s = true; s true int Alice = 0; Alice 0 int Bob = 0; Bob 0 for(int i = 0;i < N;i++){
            a[i] = scanner.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            a[i] = scanner.nextInt();
        } {
            a[i] = scanner.nextInt();
        } a[i] = scanner.nextInt() a[i] a i scanner.nextInt() scanner.nextInt scanner Arrays.sort(a, Comparator.reverseOrder()) Arrays.sort Arrays a Comparator.reverseOrder() Comparator.reverseOrder Comparator for(int i = 0;i < N;i++){
            if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
            s = !s;
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
            s = !s;
        } {
            if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
            s = !s;
        } if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            } s {
                Alice += a[i];
            } Alice += a[i] Alice a[i] a i {
                Bob += a[i];
            } Bob += a[i] Bob a[i] a i s = !s s !s s 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 scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Integer a[] = new Integer[N];
        boolean s = true;
        int Alice = 0;
        int Bob = 0;

        for(int i = 0;i < N;i++){
            a[i] = scanner.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());
        for(int i = 0;i < N;i++){
            if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
            s = !s;
        }

        System.out.println(Alice - Bob);
        }
} public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Integer a[] = new Integer[N];
        boolean s = true;
        int Alice = 0;
        int Bob = 0;

        for(int i = 0;i < N;i++){
            a[i] = scanner.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());
        for(int i = 0;i < N;i++){
            if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
            s = !s;
        }

        System.out.println(Alice - Bob);
        }
} Main
import java.util.*;
import java.util.ArrayList;
public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Integer a[] = new Integer[N];
        boolean s = true;
        int Alice = 0;
        int Bob = 0;

        for(int i = 0;i < N;i++){
            a[i] = scanner.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());
        for(int i = 0;i < N;i++){
            if(s){
                Alice += a[i];
            }else{
                Bob += a[i];
            }
            s = !s;
        }

        System.out.println(Alice - Bob);
        }
}