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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = sc.nextInt();
        }
        System.out.println(calc(N,a));
    }

    public static int calc(int N, int[] a) {
        int allice = 0;
        int bob = 0;
        Arrays.sort(a);
        for (int i=N-1; i>=0; i-=2) {
            allice += a[i];
            if (i>=1) bob += a[i-1];
        }
        return allice - bob;
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = sc.nextInt();
        }
        System.out.println(calc(N,a));
    }

    public static int calc(int N, int[] a) {
        int allice = 0;
        int bob = 0;
        Arrays.sort(a);
        for (int i=N-1; i>=0; i-=2) {
            allice += a[i];
            if (i>=1) bob += a[i-1];
        }
        return allice - bob;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = sc.nextInt();
        }
        System.out.println(calc(N,a));
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = sc.nextInt();
        }
        System.out.println(calc(N,a));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) 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 System.out.println(calc(N,a)) System.out.println System.out System System.out calc(N,a) calc N a String[] args args public static int calc(int N, int[] a) {
        int allice = 0;
        int bob = 0;
        Arrays.sort(a);
        for (int i=N-1; i>=0; i-=2) {
            allice += a[i];
            if (i>=1) bob += a[i-1];
        }
        return allice - bob;
    } calc {
        int allice = 0;
        int bob = 0;
        Arrays.sort(a);
        for (int i=N-1; i>=0; i-=2) {
            allice += a[i];
            if (i>=1) bob += a[i-1];
        }
        return allice - bob;
    } int allice = 0; allice 0 int bob = 0; bob 0 Arrays.sort(a) Arrays.sort Arrays a for (int i=N-1; i>=0; i-=2) {
            allice += a[i];
            if (i>=1) bob += a[i-1];
        } int i=N-1; int i=N-1; i N-1 N 1 i>=0 i 0 i-=2 i-=2 i 2 {
            allice += a[i];
            if (i>=1) bob += a[i-1];
        } {
            allice += a[i];
            if (i>=1) bob += a[i-1];
        } allice += a[i] allice a[i] a i if (i>=1) bob += a[i-1]; i>=1 i 1 bob += a[i-1] bob a[i-1] a i-1 i 1 return allice - bob; allice - bob allice bob int N N int[] a a public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = sc.nextInt();
        }
        System.out.println(calc(N,a));
    }

    public static int calc(int N, int[] a) {
        int allice = 0;
        int bob = 0;
        Arrays.sort(a);
        for (int i=N-1; i>=0; i-=2) {
            allice += a[i];
            if (i>=1) bob += a[i-1];
        }
        return allice - bob;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = sc.nextInt();
        }
        System.out.println(calc(N,a));
    }

    public static int calc(int N, int[] a) {
        int allice = 0;
        int bob = 0;
        Arrays.sort(a);
        for (int i=N-1; i>=0; i-=2) {
            allice += a[i];
            if (i>=1) bob += a[i-1];
        }
        return allice - bob;
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = sc.nextInt();
        }
        System.out.println(calc(N,a));
    }

    public static int calc(int N, int[] a) {
        int allice = 0;
        int bob = 0;
        Arrays.sort(a);
        for (int i=N-1; i>=0; i-=2) {
            allice += a[i];
            if (i>=1) bob += a[i-1];
        }
        return allice - bob;
    }
}
