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


class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int[] a = new int[N];

        for ( int i = 0; i < N; i++ ){
            a[i] = sc.nextInt();
        }
        sortTheCards(N, a);
        System.out.println(dealTheCards(N, a));
    }
    private static void sortTheCards(int N, int[] a){
        Arrays.sort(a);
    }
    private static int dealTheCards(int N, int[] a){
        int sub = 0;
        int absSub = 0;
        int Alice = 0;
        int Bob = 0;
        for( int i = 0; i < N; i++){
            if( i % 2 == 0 ){
                Alice += a[i];
            }else{
                Bob += a[i];                
            }
        }
        sub = Alice - Bob;
        absSub = Math.abs(sub);
        return absSub;
    }
} import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int[] a = new int[N];

        for ( int i = 0; i < N; i++ ){
            a[i] = sc.nextInt();
        }
        sortTheCards(N, a);
        System.out.println(dealTheCards(N, a));
    }
    private static void sortTheCards(int N, int[] a){
        Arrays.sort(a);
    }
    private static int dealTheCards(int N, int[] a){
        int sub = 0;
        int absSub = 0;
        int Alice = 0;
        int Bob = 0;
        for( int i = 0; i < N; i++){
            if( i % 2 == 0 ){
                Alice += a[i];
            }else{
                Bob += a[i];                
            }
        }
        sub = Alice - Bob;
        absSub = Math.abs(sub);
        return absSub;
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int[] a = new int[N];

        for ( int i = 0; i < N; i++ ){
            a[i] = sc.nextInt();
        }
        sortTheCards(N, a);
        System.out.println(dealTheCards(N, a));
    } main {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int[] a = new int[N];

        for ( int i = 0; i < N; i++ ){
            a[i] = sc.nextInt();
        }
        sortTheCards(N, a);
        System.out.println(dealTheCards(N, a));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc final 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 sortTheCards(N, a) sortTheCards N a System.out.println(dealTheCards(N, a)) System.out.println System.out System System.out dealTheCards(N, a) dealTheCards N a String[] args args private static void sortTheCards(int N, int[] a){
        Arrays.sort(a);
    } sortTheCards {
        Arrays.sort(a);
    } Arrays.sort(a) Arrays.sort Arrays a int N N int[] a a private static int dealTheCards(int N, int[] a){
        int sub = 0;
        int absSub = 0;
        int Alice = 0;
        int Bob = 0;
        for( int i = 0; i < N; i++){
            if( i % 2 == 0 ){
                Alice += a[i];
            }else{
                Bob += a[i];                
            }
        }
        sub = Alice - Bob;
        absSub = Math.abs(sub);
        return absSub;
    } dealTheCards {
        int sub = 0;
        int absSub = 0;
        int Alice = 0;
        int Bob = 0;
        for( int i = 0; i < N; i++){
            if( i % 2 == 0 ){
                Alice += a[i];
            }else{
                Bob += a[i];                
            }
        }
        sub = Alice - Bob;
        absSub = Math.abs(sub);
        return absSub;
    } int sub = 0; sub 0 int absSub = 0; absSub 0 int Alice = 0; Alice 0 int Bob = 0; Bob 0 for( int i = 0; i < N; i++){
            if( i % 2 == 0 ){
                Alice += a[i];
            }else{
                Bob += a[i];                
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if( i % 2 == 0 ){
                Alice += a[i];
            }else{
                Bob += a[i];                
            }
        } {
            if( i % 2 == 0 ){
                Alice += a[i];
            }else{
                Bob += a[i];                
            }
        } if( i % 2 == 0 ){
                Alice += a[i];
            }else{
                Bob += a[i];                
            } i % 2 == 0 i % 2 i 2 0 {
                Alice += a[i];
            } Alice += a[i] Alice a[i] a i {
                Bob += a[i];                
            } Bob += a[i] Bob a[i] a i sub = Alice - Bob sub Alice - Bob Alice Bob absSub = Math.abs(sub) absSub Math.abs(sub) Math.abs Math sub return absSub; absSub int N N int[] a a
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;


class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int[] a = new int[N];

        for ( int i = 0; i < N; i++ ){
            a[i] = sc.nextInt();
        }
        sortTheCards(N, a);
        System.out.println(dealTheCards(N, a));
    }
    private static void sortTheCards(int N, int[] a){
        Arrays.sort(a);
    }
    private static int dealTheCards(int N, int[] a){
        int sub = 0;
        int absSub = 0;
        int Alice = 0;
        int Bob = 0;
        for( int i = 0; i < N; i++){
            if( i % 2 == 0 ){
                Alice += a[i];
            }else{
                Bob += a[i];                
            }
        }
        sub = Alice - Bob;
        absSub = Math.abs(sub);
        return absSub;
    }
}