import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for (int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int diff = 0;
        for (int i=0;i<n/2;i++) {
            diff += a[2*i] - a[2*i+1];
        }
        if ((n & 1) == 1)
            diff += a[n-1];
        System.out.println(diff);
    }
} 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[] a = new Integer[n];
        for (int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int diff = 0;
        for (int i=0;i<n/2;i++) {
            diff += a[2*i] - a[2*i+1];
        }
        if ((n & 1) == 1)
            diff += a[n-1];
        System.out.println(diff);
    }
} Main public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for (int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int diff = 0;
        for (int i=0;i<n/2;i++) {
            diff += a[2*i] - a[2*i+1];
        }
        if ((n & 1) == 1)
            diff += a[n-1];
        System.out.println(diff);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for (int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int diff = 0;
        for (int i=0;i<n/2;i++) {
            diff += a[2*i] - a[2*i+1];
        }
        if ((n & 1) == 1)
            diff += a[n-1];
        System.out.println(diff);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Integer[] a = new Integer[n]; a new Integer[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, Comparator.reverseOrder()) Arrays.sort Arrays a Comparator.reverseOrder() Comparator.reverseOrder Comparator int diff = 0; diff 0 for (int i=0;i<n/2;i++) {
            diff += a[2*i] - a[2*i+1];
        } int i=0; int i=0; i 0 i<n/2 i n/2 n 2 i++ i++ i {
            diff += a[2*i] - a[2*i+1];
        } {
            diff += a[2*i] - a[2*i+1];
        } diff += a[2*i] - a[2*i+1] diff a[2*i] - a[2*i+1] a[2*i] a 2*i 2 i a[2*i+1] a 2*i+1 2*i 2 i 1 if ((n & 1) == 1)
            diff += a[n-1]; (n & 1) == 1 (n & 1) n 1 1 diff += a[n-1] diff a[n-1] a n-1 n 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 sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for (int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int diff = 0;
        for (int i=0;i<n/2;i++) {
            diff += a[2*i] - a[2*i+1];
        }
        if ((n & 1) == 1)
            diff += a[n-1];
        System.out.println(diff);
    }
} public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for (int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int diff = 0;
        for (int i=0;i<n/2;i++) {
            diff += a[2*i] - a[2*i+1];
        }
        if ((n & 1) == 1)
            diff += a[n-1];
        System.out.println(diff);
    }
} Main
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for (int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int diff = 0;
        for (int i=0;i<n/2;i++) {
            diff += a[2*i] - a[2*i+1];
        }
        if ((n & 1) == 1)
            diff += a[n-1];
        System.out.println(diff);
    }
}