

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

public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int score = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            }
        }
        System.out.println(Math.abs(score));
    }

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int score = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            }
        }
        System.out.println(Math.abs(score));
    }

} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int score = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            }
        }
        System.out.println(Math.abs(score));
    } main {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int score = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            }
        }
        System.out.println(Math.abs(score));
    } int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] a = new int[n]; a new int[n] n for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a[i] = sc.nextInt();
        } {
            a[i] = sc.nextInt();
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc Arrays.sort(a) Arrays.sort Arrays a int score = 0; score 0 for (int i = n - 1; i >= 0; i--) {
            if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            }
        } int i = n - 1; int i = n - 1; i n - 1 n 1 i >= 0 i 0 i-- i-- i {
            if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            }
        } {
            if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            }
        } if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            } i % 2 ==1 i % 2 i 2 1 {
                score += a[i];
            } score += a[i] score a[i] a i {
                score -= a[i];
            } score -= a[i] score a[i] a i System.out.println(Math.abs(score)) System.out.println System.out System System.out Math.abs(score) Math.abs Math score String[] args args public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int score = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            }
        }
        System.out.println(Math.abs(score));
    }

} public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int score = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            }
        }
        System.out.println(Math.abs(score));
    }

} Main


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

public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int score = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            }
        }
        System.out.println(Math.abs(score));
    }

}
