import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        Integer[] numList = new Integer[n];
        for (int i = 0; i < n; i++) {
            numList[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(numList, Collections.reverseOrder());
        int sumAlice = 0;
        int sumBob = 0;
        for (int i = 0; i < numList.length; i++) {
            if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            }
        }

        System.out.println(sumAlice - sumBob);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        Integer[] numList = new Integer[n];
        for (int i = 0; i < n; i++) {
            numList[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(numList, Collections.reverseOrder());
        int sumAlice = 0;
        int sumBob = 0;
        for (int i = 0; i < numList.length; i++) {
            if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            }
        }

        System.out.println(sumAlice - sumBob);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        Integer[] numList = new Integer[n];
        for (int i = 0; i < n; i++) {
            numList[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(numList, Collections.reverseOrder());
        int sumAlice = 0;
        int sumBob = 0;
        for (int i = 0; i < numList.length; i++) {
            if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            }
        }

        System.out.println(sumAlice - sumBob);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        Integer[] numList = new Integer[n];
        for (int i = 0; i < n; i++) {
            numList[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(numList, Collections.reverseOrder());
        int sumAlice = 0;
        int sumBob = 0;
        for (int i = 0; i < numList.length; i++) {
            if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            }
        }

        System.out.println(sumAlice - sumBob);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Integer[] numList = new Integer[n]; numList new Integer[n] n for (int i = 0; i < n; i++) {
            numList[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            numList[i] = Integer.parseInt(sc.next());
        } {
            numList[i] = Integer.parseInt(sc.next());
        } numList[i] = Integer.parseInt(sc.next()) numList[i] numList i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(numList, Collections.reverseOrder()) Arrays.sort Arrays numList Collections.reverseOrder() Collections.reverseOrder Collections int sumAlice = 0; sumAlice 0 int sumBob = 0; sumBob 0 for (int i = 0; i < numList.length; i++) {
            if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            }
        } int i = 0; int i = 0; i 0 i < numList.length i numList.length numList numList.length i++ i++ i {
            if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            }
        } {
            if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            }
        } if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            } i % 2 == 0 i % 2 i 2 0 {
                sumAlice += numList[i];
            } sumAlice += numList[i] sumAlice numList[i] numList i {
                sumBob += numList[i];
            } sumBob += numList[i] sumBob numList[i] numList i System.out.println(sumAlice - sumBob) System.out.println System.out System System.out sumAlice - sumBob sumAlice sumBob String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        Integer[] numList = new Integer[n];
        for (int i = 0; i < n; i++) {
            numList[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(numList, Collections.reverseOrder());
        int sumAlice = 0;
        int sumBob = 0;
        for (int i = 0; i < numList.length; i++) {
            if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            }
        }

        System.out.println(sumAlice - sumBob);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        Integer[] numList = new Integer[n];
        for (int i = 0; i < n; i++) {
            numList[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(numList, Collections.reverseOrder());
        int sumAlice = 0;
        int sumBob = 0;
        for (int i = 0; i < numList.length; i++) {
            if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            }
        }

        System.out.println(sumAlice - sumBob);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        Integer[] numList = new Integer[n];
        for (int i = 0; i < n; i++) {
            numList[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(numList, Collections.reverseOrder());
        int sumAlice = 0;
        int sumBob = 0;
        for (int i = 0; i < numList.length; i++) {
            if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            }
        }

        System.out.println(sumAlice - sumBob);
    }
}
