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();
        }

        Arrays.sort(a);

        int totala = 0;
        int totalb = 0;
        for (int i = a.length - 1; i >= 0; i -= 2) {
            totala += a[i];
            if (i > 0) {
                totalb += a[i - 1];
            }
        }

        System.out.println(totala - totalb);
    }
} 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();
        }

        Arrays.sort(a);

        int totala = 0;
        int totalb = 0;
        for (int i = a.length - 1; i >= 0; i -= 2) {
            totala += a[i];
            if (i > 0) {
                totalb += a[i - 1];
            }
        }

        System.out.println(totala - totalb);
    }
} 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();
        }

        Arrays.sort(a);

        int totala = 0;
        int totalb = 0;
        for (int i = a.length - 1; i >= 0; i -= 2) {
            totala += a[i];
            if (i > 0) {
                totalb += a[i - 1];
            }
        }

        System.out.println(totala - totalb);
    } 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();
        }

        Arrays.sort(a);

        int totala = 0;
        int totalb = 0;
        for (int i = a.length - 1; i >= 0; i -= 2) {
            totala += a[i];
            if (i > 0) {
                totalb += a[i - 1];
            }
        }

        System.out.println(totala - totalb);
    } 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 Arrays.sort(a) Arrays.sort Arrays a int totala = 0; totala 0 int totalb = 0; totalb 0 for (int i = a.length - 1; i >= 0; i -= 2) {
            totala += a[i];
            if (i > 0) {
                totalb += a[i - 1];
            }
        } int i = a.length - 1; int i = a.length - 1; i a.length - 1 a.length a a.length 1 i >= 0 i 0 i -= 2 i -= 2 i 2 {
            totala += a[i];
            if (i > 0) {
                totalb += a[i - 1];
            }
        } {
            totala += a[i];
            if (i > 0) {
                totalb += a[i - 1];
            }
        } totala += a[i] totala a[i] a i if (i > 0) {
                totalb += a[i - 1];
            } i > 0 i 0 {
                totalb += a[i - 1];
            } totalb += a[i - 1] totalb a[i - 1] a i - 1 i 1 System.out.println(totala - totalb) System.out.println System.out System System.out totala - totalb totala totalb String[] args args 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();
        }

        Arrays.sort(a);

        int totala = 0;
        int totalb = 0;
        for (int i = a.length - 1; i >= 0; i -= 2) {
            totala += a[i];
            if (i > 0) {
                totalb += a[i - 1];
            }
        }

        System.out.println(totala - totalb);
    }
} 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();
        }

        Arrays.sort(a);

        int totala = 0;
        int totalb = 0;
        for (int i = a.length - 1; i >= 0; i -= 2) {
            totala += a[i];
            if (i > 0) {
                totalb += a[i - 1];
            }
        }

        System.out.println(totala - totalb);
    }
} 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();
        }

        Arrays.sort(a);

        int totala = 0;
        int totalb = 0;
        for (int i = a.length - 1; i >= 0; i -= 2) {
            totala += a[i];
            if (i > 0) {
                totalb += a[i - 1];
            }
        }

        System.out.println(totala - totalb);
    }
}
