import java.util.*;

public class Main {

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

        for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        }

        Arrays.sort(aArr, Collections.reverseOrder());

        int scoreA = 0;
        int scoreB = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                scoreA += aArr[i];
            } else {
                scoreB += aArr[i];
            }
        }

        System.out.println(scoreA - scoreB);
    }
} import java.util.*; util.* java public class Main {

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

        for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        }

        Arrays.sort(aArr, Collections.reverseOrder());

        int scoreA = 0;
        int scoreB = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                scoreA += aArr[i];
            } else {
                scoreB += aArr[i];
            }
        }

        System.out.println(scoreA - scoreB);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] aArr = new Integer[n];

        for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        }

        Arrays.sort(aArr, Collections.reverseOrder());

        int scoreA = 0;
        int scoreB = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                scoreA += aArr[i];
            } else {
                scoreB += aArr[i];
            }
        }

        System.out.println(scoreA - scoreB);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] aArr = new Integer[n];

        for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        }

        Arrays.sort(aArr, Collections.reverseOrder());

        int scoreA = 0;
        int scoreB = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                scoreA += aArr[i];
            } else {
                scoreB += aArr[i];
            }
        }

        System.out.println(scoreA - scoreB);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Integer[] aArr = new Integer[n]; aArr new Integer[n] n for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            aArr[i] = sc.nextInt();
        } {
            aArr[i] = sc.nextInt();
        } aArr[i] = sc.nextInt() aArr[i] aArr i sc.nextInt() sc.nextInt sc Arrays.sort(aArr, Collections.reverseOrder()) Arrays.sort Arrays aArr Collections.reverseOrder() Collections.reverseOrder Collections int scoreA = 0; scoreA 0 int scoreB = 0; scoreB 0 for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                scoreA += aArr[i];
            } else {
                scoreB += aArr[i];
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if (i % 2 == 0) {
                scoreA += aArr[i];
            } else {
                scoreB += aArr[i];
            }
        } {
            if (i % 2 == 0) {
                scoreA += aArr[i];
            } else {
                scoreB += aArr[i];
            }
        } if (i % 2 == 0) {
                scoreA += aArr[i];
            } else {
                scoreB += aArr[i];
            } i % 2 == 0 i % 2 i 2 0 {
                scoreA += aArr[i];
            } scoreA += aArr[i] scoreA aArr[i] aArr i {
                scoreB += aArr[i];
            } scoreB += aArr[i] scoreB aArr[i] aArr i System.out.println(scoreA - scoreB) System.out.println System.out System System.out scoreA - scoreB scoreA scoreB String[] args args public class Main {

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

        for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        }

        Arrays.sort(aArr, Collections.reverseOrder());

        int scoreA = 0;
        int scoreB = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                scoreA += aArr[i];
            } else {
                scoreB += aArr[i];
            }
        }

        System.out.println(scoreA - scoreB);
    }
} public class Main {

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

        for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        }

        Arrays.sort(aArr, Collections.reverseOrder());

        int scoreA = 0;
        int scoreB = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                scoreA += aArr[i];
            } else {
                scoreB += aArr[i];
            }
        }

        System.out.println(scoreA - scoreB);
    }
} Main
import java.util.*;

public class Main {

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

        for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        }

        Arrays.sort(aArr, Collections.reverseOrder());

        int scoreA = 0;
        int scoreB = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                scoreA += aArr[i];
            } else {
                scoreB += aArr[i];
            }
        }

        System.out.println(scoreA - scoreB);
    }
}
