import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        List<Integer> list = new ArrayList(N);

        for (int i = 0; i < N; i++) {
            list.add(scanner.nextInt());
        }

        Collections.sort(list, Collections.reverseOrder());

        int aTotal = 0;
        int bTotal = 0;

        for (int i = 0; i < N; i++) {
            if ((i & 1) == 0) {
                aTotal += list.get(i);
            } else {
                bTotal += list.get(i);
            }
        }

        System.out.println(aTotal - bTotal);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        List<Integer> list = new ArrayList(N);

        for (int i = 0; i < N; i++) {
            list.add(scanner.nextInt());
        }

        Collections.sort(list, Collections.reverseOrder());

        int aTotal = 0;
        int bTotal = 0;

        for (int i = 0; i < N; i++) {
            if ((i & 1) == 0) {
                aTotal += list.get(i);
            } else {
                bTotal += list.get(i);
            }
        }

        System.out.println(aTotal - bTotal);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        List<Integer> list = new ArrayList(N);

        for (int i = 0; i < N; i++) {
            list.add(scanner.nextInt());
        }

        Collections.sort(list, Collections.reverseOrder());

        int aTotal = 0;
        int bTotal = 0;

        for (int i = 0; i < N; i++) {
            if ((i & 1) == 0) {
                aTotal += list.get(i);
            } else {
                bTotal += list.get(i);
            }
        }

        System.out.println(aTotal - bTotal);
    } main {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        List<Integer> list = new ArrayList(N);

        for (int i = 0; i < N; i++) {
            list.add(scanner.nextInt());
        }

        Collections.sort(list, Collections.reverseOrder());

        int aTotal = 0;
        int bTotal = 0;

        for (int i = 0; i < N; i++) {
            if ((i & 1) == 0) {
                aTotal += list.get(i);
            } else {
                bTotal += list.get(i);
            }
        }

        System.out.println(aTotal - bTotal);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner List<Integer> list = new ArrayList(N); list new ArrayList(N) for (int i = 0; i < N; i++) {
            list.add(scanner.nextInt());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            list.add(scanner.nextInt());
        } {
            list.add(scanner.nextInt());
        } list.add(scanner.nextInt()) list.add list scanner.nextInt() scanner.nextInt scanner Collections.sort(list, Collections.reverseOrder()) Collections.sort Collections list Collections.reverseOrder() Collections.reverseOrder Collections int aTotal = 0; aTotal 0 int bTotal = 0; bTotal 0 for (int i = 0; i < N; i++) {
            if ((i & 1) == 0) {
                aTotal += list.get(i);
            } else {
                bTotal += list.get(i);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if ((i & 1) == 0) {
                aTotal += list.get(i);
            } else {
                bTotal += list.get(i);
            }
        } {
            if ((i & 1) == 0) {
                aTotal += list.get(i);
            } else {
                bTotal += list.get(i);
            }
        } if ((i & 1) == 0) {
                aTotal += list.get(i);
            } else {
                bTotal += list.get(i);
            } (i & 1) == 0 (i & 1) i 1 0 {
                aTotal += list.get(i);
            } aTotal += list.get(i) aTotal list.get(i) list.get list i {
                bTotal += list.get(i);
            } bTotal += list.get(i) bTotal list.get(i) list.get list i System.out.println(aTotal - bTotal) System.out.println System.out System System.out aTotal - bTotal aTotal bTotal String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        List<Integer> list = new ArrayList(N);

        for (int i = 0; i < N; i++) {
            list.add(scanner.nextInt());
        }

        Collections.sort(list, Collections.reverseOrder());

        int aTotal = 0;
        int bTotal = 0;

        for (int i = 0; i < N; i++) {
            if ((i & 1) == 0) {
                aTotal += list.get(i);
            } else {
                bTotal += list.get(i);
            }
        }

        System.out.println(aTotal - bTotal);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        List<Integer> list = new ArrayList(N);

        for (int i = 0; i < N; i++) {
            list.add(scanner.nextInt());
        }

        Collections.sort(list, Collections.reverseOrder());

        int aTotal = 0;
        int bTotal = 0;

        for (int i = 0; i < N; i++) {
            if ((i & 1) == 0) {
                aTotal += list.get(i);
            } else {
                bTotal += list.get(i);
            }
        }

        System.out.println(aTotal - bTotal);
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        List<Integer> list = new ArrayList(N);

        for (int i = 0; i < N; i++) {
            list.add(scanner.nextInt());
        }

        Collections.sort(list, Collections.reverseOrder());

        int aTotal = 0;
        int bTotal = 0;

        for (int i = 0; i < N; i++) {
            if ((i & 1) == 0) {
                aTotal += list.get(i);
            } else {
                bTotal += list.get(i);
            }
        }

        System.out.println(aTotal - bTotal);
    }
}