import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner dataScanner = new Scanner(System.in);
        int numCards = Integer.parseInt(dataScanner.nextLine());
        String[] dataStr = dataScanner.nextLine().split(" ");
        int[] dataInt= new int[numCards];
        for (int i = 0; i < numCards; i++) {
            dataInt[i] = Integer.parseInt(dataStr[i]);
        }
        Arrays.sort(dataInt);
        int diff = 0;
        for (int i = 0; i < numCards; i++) {
            if (i % 2 == 0) {
                diff = diff + dataInt[numCards - i - 1];
            } else {
                diff = diff - dataInt[numCards - i - 1];
            }
        }
        System.out.println(diff);
    }
} import java.util.*; util.* java import java.lang.*; lang.* java public class Main {
    public static void main(String[] args) {
        Scanner dataScanner = new Scanner(System.in);
        int numCards = Integer.parseInt(dataScanner.nextLine());
        String[] dataStr = dataScanner.nextLine().split(" ");
        int[] dataInt= new int[numCards];
        for (int i = 0; i < numCards; i++) {
            dataInt[i] = Integer.parseInt(dataStr[i]);
        }
        Arrays.sort(dataInt);
        int diff = 0;
        for (int i = 0; i < numCards; i++) {
            if (i % 2 == 0) {
                diff = diff + dataInt[numCards - i - 1];
            } else {
                diff = diff - dataInt[numCards - i - 1];
            }
        }
        System.out.println(diff);
    }
} Main public static void main(String[] args) {
        Scanner dataScanner = new Scanner(System.in);
        int numCards = Integer.parseInt(dataScanner.nextLine());
        String[] dataStr = dataScanner.nextLine().split(" ");
        int[] dataInt= new int[numCards];
        for (int i = 0; i < numCards; i++) {
            dataInt[i] = Integer.parseInt(dataStr[i]);
        }
        Arrays.sort(dataInt);
        int diff = 0;
        for (int i = 0; i < numCards; i++) {
            if (i % 2 == 0) {
                diff = diff + dataInt[numCards - i - 1];
            } else {
                diff = diff - dataInt[numCards - i - 1];
            }
        }
        System.out.println(diff);
    } main {
        Scanner dataScanner = new Scanner(System.in);
        int numCards = Integer.parseInt(dataScanner.nextLine());
        String[] dataStr = dataScanner.nextLine().split(" ");
        int[] dataInt= new int[numCards];
        for (int i = 0; i < numCards; i++) {
            dataInt[i] = Integer.parseInt(dataStr[i]);
        }
        Arrays.sort(dataInt);
        int diff = 0;
        for (int i = 0; i < numCards; i++) {
            if (i % 2 == 0) {
                diff = diff + dataInt[numCards - i - 1];
            } else {
                diff = diff - dataInt[numCards - i - 1];
            }
        }
        System.out.println(diff);
    } Scanner dataScanner = new Scanner(System.in); dataScanner new Scanner(System.in) int numCards = Integer.parseInt(dataScanner.nextLine()); numCards Integer.parseInt(dataScanner.nextLine()) Integer.parseInt Integer dataScanner.nextLine() dataScanner.nextLine dataScanner String[] dataStr = dataScanner.nextLine().split(" "); dataStr dataScanner.nextLine().split(" ") dataScanner.nextLine().split dataScanner.nextLine() dataScanner.nextLine dataScanner " " int[] dataInt= new int[numCards]; dataInt new int[numCards] numCards for (int i = 0; i < numCards; i++) {
            dataInt[i] = Integer.parseInt(dataStr[i]);
        } int i = 0; int i = 0; i 0 i < numCards i numCards i++ i++ i {
            dataInt[i] = Integer.parseInt(dataStr[i]);
        } {
            dataInt[i] = Integer.parseInt(dataStr[i]);
        } dataInt[i] = Integer.parseInt(dataStr[i]) dataInt[i] dataInt i Integer.parseInt(dataStr[i]) Integer.parseInt Integer dataStr[i] dataStr i Arrays.sort(dataInt) Arrays.sort Arrays dataInt int diff = 0; diff 0 for (int i = 0; i < numCards; i++) {
            if (i % 2 == 0) {
                diff = diff + dataInt[numCards - i - 1];
            } else {
                diff = diff - dataInt[numCards - i - 1];
            }
        } int i = 0; int i = 0; i 0 i < numCards i numCards i++ i++ i {
            if (i % 2 == 0) {
                diff = diff + dataInt[numCards - i - 1];
            } else {
                diff = diff - dataInt[numCards - i - 1];
            }
        } {
            if (i % 2 == 0) {
                diff = diff + dataInt[numCards - i - 1];
            } else {
                diff = diff - dataInt[numCards - i - 1];
            }
        } if (i % 2 == 0) {
                diff = diff + dataInt[numCards - i - 1];
            } else {
                diff = diff - dataInt[numCards - i - 1];
            } i % 2 == 0 i % 2 i 2 0 {
                diff = diff + dataInt[numCards - i - 1];
            } diff = diff + dataInt[numCards - i - 1] diff diff + dataInt[numCards - i - 1] diff dataInt[numCards - i - 1] dataInt numCards - i - 1 numCards - i - 1 numCards i 1 {
                diff = diff - dataInt[numCards - i - 1];
            } diff = diff - dataInt[numCards - i - 1] diff diff - dataInt[numCards - i - 1] diff dataInt[numCards - i - 1] dataInt numCards - i - 1 numCards - i - 1 numCards i 1 System.out.println(diff) System.out.println System.out System System.out diff String[] args args public class Main {
    public static void main(String[] args) {
        Scanner dataScanner = new Scanner(System.in);
        int numCards = Integer.parseInt(dataScanner.nextLine());
        String[] dataStr = dataScanner.nextLine().split(" ");
        int[] dataInt= new int[numCards];
        for (int i = 0; i < numCards; i++) {
            dataInt[i] = Integer.parseInt(dataStr[i]);
        }
        Arrays.sort(dataInt);
        int diff = 0;
        for (int i = 0; i < numCards; i++) {
            if (i % 2 == 0) {
                diff = diff + dataInt[numCards - i - 1];
            } else {
                diff = diff - dataInt[numCards - i - 1];
            }
        }
        System.out.println(diff);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner dataScanner = new Scanner(System.in);
        int numCards = Integer.parseInt(dataScanner.nextLine());
        String[] dataStr = dataScanner.nextLine().split(" ");
        int[] dataInt= new int[numCards];
        for (int i = 0; i < numCards; i++) {
            dataInt[i] = Integer.parseInt(dataStr[i]);
        }
        Arrays.sort(dataInt);
        int diff = 0;
        for (int i = 0; i < numCards; i++) {
            if (i % 2 == 0) {
                diff = diff + dataInt[numCards - i - 1];
            } else {
                diff = diff - dataInt[numCards - i - 1];
            }
        }
        System.out.println(diff);
    }
} Main
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner dataScanner = new Scanner(System.in);
        int numCards = Integer.parseInt(dataScanner.nextLine());
        String[] dataStr = dataScanner.nextLine().split(" ");
        int[] dataInt= new int[numCards];
        for (int i = 0; i < numCards; i++) {
            dataInt[i] = Integer.parseInt(dataStr[i]);
        }
        Arrays.sort(dataInt);
        int diff = 0;
        for (int i = 0; i < numCards; i++) {
            if (i % 2 == 0) {
                diff = diff + dataInt[numCards - i - 1];
            } else {
                diff = diff - dataInt[numCards - i - 1];
            }
        }
        System.out.println(diff);
    }
}
