import java.util.Arrays;
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();

        int[] cardList = new int[n];
        int[] player = new int[2];
        for(int i=0;i<n;i++){
            cardList[i] = s.nextInt();
        }

        Arrays.sort(cardList);

        int switchPlayer = 0;

        for(int i=n-1;i>=0;i--){
            if(switchPlayer == 0){
                player[0] += cardList[i];
                switchPlayer = 1;
            } else {
                player[1] += cardList[i];
                switchPlayer = 0;
            }
        }

        System.out.println(player[0] - player[1]);


    }

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main{

    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();

        int[] cardList = new int[n];
        int[] player = new int[2];
        for(int i=0;i<n;i++){
            cardList[i] = s.nextInt();
        }

        Arrays.sort(cardList);

        int switchPlayer = 0;

        for(int i=n-1;i>=0;i--){
            if(switchPlayer == 0){
                player[0] += cardList[i];
                switchPlayer = 1;
            } else {
                player[1] += cardList[i];
                switchPlayer = 0;
            }
        }

        System.out.println(player[0] - player[1]);


    }

} Main public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();

        int[] cardList = new int[n];
        int[] player = new int[2];
        for(int i=0;i<n;i++){
            cardList[i] = s.nextInt();
        }

        Arrays.sort(cardList);

        int switchPlayer = 0;

        for(int i=n-1;i>=0;i--){
            if(switchPlayer == 0){
                player[0] += cardList[i];
                switchPlayer = 1;
            } else {
                player[1] += cardList[i];
                switchPlayer = 0;
            }
        }

        System.out.println(player[0] - player[1]);


    } main {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();

        int[] cardList = new int[n];
        int[] player = new int[2];
        for(int i=0;i<n;i++){
            cardList[i] = s.nextInt();
        }

        Arrays.sort(cardList);

        int switchPlayer = 0;

        for(int i=n-1;i>=0;i--){
            if(switchPlayer == 0){
                player[0] += cardList[i];
                switchPlayer = 1;
            } else {
                player[1] += cardList[i];
                switchPlayer = 0;
            }
        }

        System.out.println(player[0] - player[1]);


    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int[] cardList = new int[n]; cardList new int[n] n int[] player = new int[2]; player new int[2] 2 for(int i=0;i<n;i++){
            cardList[i] = s.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            cardList[i] = s.nextInt();
        } {
            cardList[i] = s.nextInt();
        } cardList[i] = s.nextInt() cardList[i] cardList i s.nextInt() s.nextInt s Arrays.sort(cardList) Arrays.sort Arrays cardList int switchPlayer = 0; switchPlayer 0 for(int i=n-1;i>=0;i--){
            if(switchPlayer == 0){
                player[0] += cardList[i];
                switchPlayer = 1;
            } else {
                player[1] += cardList[i];
                switchPlayer = 0;
            }
        } int i=n-1; int i=n-1; i n-1 n 1 i>=0 i 0 i-- i-- i {
            if(switchPlayer == 0){
                player[0] += cardList[i];
                switchPlayer = 1;
            } else {
                player[1] += cardList[i];
                switchPlayer = 0;
            }
        } {
            if(switchPlayer == 0){
                player[0] += cardList[i];
                switchPlayer = 1;
            } else {
                player[1] += cardList[i];
                switchPlayer = 0;
            }
        } if(switchPlayer == 0){
                player[0] += cardList[i];
                switchPlayer = 1;
            } else {
                player[1] += cardList[i];
                switchPlayer = 0;
            } switchPlayer == 0 switchPlayer 0 {
                player[0] += cardList[i];
                switchPlayer = 1;
            } player[0] += cardList[i] player[0] player 0 cardList[i] cardList i switchPlayer = 1 switchPlayer 1 {
                player[1] += cardList[i];
                switchPlayer = 0;
            } player[1] += cardList[i] player[1] player 1 cardList[i] cardList i switchPlayer = 0 switchPlayer 0 System.out.println(player[0] - player[1]) System.out.println System.out System System.out player[0] - player[1] player[0] player 0 player[1] player 1 String[] args args public class Main{

    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();

        int[] cardList = new int[n];
        int[] player = new int[2];
        for(int i=0;i<n;i++){
            cardList[i] = s.nextInt();
        }

        Arrays.sort(cardList);

        int switchPlayer = 0;

        for(int i=n-1;i>=0;i--){
            if(switchPlayer == 0){
                player[0] += cardList[i];
                switchPlayer = 1;
            } else {
                player[1] += cardList[i];
                switchPlayer = 0;
            }
        }

        System.out.println(player[0] - player[1]);


    }

} public class Main{

    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();

        int[] cardList = new int[n];
        int[] player = new int[2];
        for(int i=0;i<n;i++){
            cardList[i] = s.nextInt();
        }

        Arrays.sort(cardList);

        int switchPlayer = 0;

        for(int i=n-1;i>=0;i--){
            if(switchPlayer == 0){
                player[0] += cardList[i];
                switchPlayer = 1;
            } else {
                player[1] += cardList[i];
                switchPlayer = 0;
            }
        }

        System.out.println(player[0] - player[1]);


    }

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();

        int[] cardList = new int[n];
        int[] player = new int[2];
        for(int i=0;i<n;i++){
            cardList[i] = s.nextInt();
        }

        Arrays.sort(cardList);

        int switchPlayer = 0;

        for(int i=n-1;i>=0;i--){
            if(switchPlayer == 0){
                player[0] += cardList[i];
                switchPlayer = 1;
            } else {
                player[1] += cardList[i];
                switchPlayer = 0;
            }
        }

        System.out.println(player[0] - player[1]);


    }

}