import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] arg = new int[n];
        for(int i=0;i<n;i++){
            arg[i] = Integer.parseInt(sc.next());
        }
        _sortInt(arg, 0, n-1);
        int asum=0, bsum=0;
        for(int i=0;i<n;i++){
            if(i%2==0){
                asum += arg[i];
            }else{
                bsum += arg[i];
            }
        }
        System.out.println(asum - bsum);
    }

    // 降順クイックソート
    private static void _sortInt(int[] d, int left, int right){
        if(left>=right){return;}
        int p = d[(left+right)/2];
        int l=left, r=right, tmp;
        while(l<r){
            while(d[l]>p){l++;}
            while(d[r]<p){r--;}
            if(l<=r){
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            }
            _sortInt(d, left, r);
            _sortInt(d, l, right);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] arg = new int[n];
        for(int i=0;i<n;i++){
            arg[i] = Integer.parseInt(sc.next());
        }
        _sortInt(arg, 0, n-1);
        int asum=0, bsum=0;
        for(int i=0;i<n;i++){
            if(i%2==0){
                asum += arg[i];
            }else{
                bsum += arg[i];
            }
        }
        System.out.println(asum - bsum);
    }

    // 降順クイックソート
    private static void _sortInt(int[] d, int left, int right){
        if(left>=right){return;}
        int p = d[(left+right)/2];
        int l=left, r=right, tmp;
        while(l<r){
            while(d[l]>p){l++;}
            while(d[r]<p){r--;}
            if(l<=r){
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            }
            _sortInt(d, left, r);
            _sortInt(d, l, right);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] arg = new int[n];
        for(int i=0;i<n;i++){
            arg[i] = Integer.parseInt(sc.next());
        }
        _sortInt(arg, 0, n-1);
        int asum=0, bsum=0;
        for(int i=0;i<n;i++){
            if(i%2==0){
                asum += arg[i];
            }else{
                bsum += arg[i];
            }
        }
        System.out.println(asum - bsum);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] arg = new int[n];
        for(int i=0;i<n;i++){
            arg[i] = Integer.parseInt(sc.next());
        }
        _sortInt(arg, 0, n-1);
        int asum=0, bsum=0;
        for(int i=0;i<n;i++){
            if(i%2==0){
                asum += arg[i];
            }else{
                bsum += arg[i];
            }
        }
        System.out.println(asum - bsum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] arg = new int[n]; arg new int[n] n for(int i=0;i<n;i++){
            arg[i] = Integer.parseInt(sc.next());
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            arg[i] = Integer.parseInt(sc.next());
        } {
            arg[i] = Integer.parseInt(sc.next());
        } arg[i] = Integer.parseInt(sc.next()) arg[i] arg i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc _sortInt(arg, 0, n-1) _sortInt arg 0 n-1 n 1 int asum=0 asum 0 bsum=0; bsum 0 for(int i=0;i<n;i++){
            if(i%2==0){
                asum += arg[i];
            }else{
                bsum += arg[i];
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            if(i%2==0){
                asum += arg[i];
            }else{
                bsum += arg[i];
            }
        } {
            if(i%2==0){
                asum += arg[i];
            }else{
                bsum += arg[i];
            }
        } if(i%2==0){
                asum += arg[i];
            }else{
                bsum += arg[i];
            } i%2==0 i%2 i 2 0 {
                asum += arg[i];
            } asum += arg[i] asum arg[i] arg i {
                bsum += arg[i];
            } bsum += arg[i] bsum arg[i] arg i System.out.println(asum - bsum) System.out.println System.out System System.out asum - bsum asum bsum String[] args args // 降順クイックソート
    private static void _sortInt(int[] d, int left, int right){
        if(left>=right){return;}
        int p = d[(left+right)/2];
        int l=left, r=right, tmp;
        while(l<r){
            while(d[l]>p){l++;}
            while(d[r]<p){r--;}
            if(l<=r){
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            }
            _sortInt(d, left, r);
            _sortInt(d, l, right);
        }
    } _sortInt {
        if(left>=right){return;}
        int p = d[(left+right)/2];
        int l=left, r=right, tmp;
        while(l<r){
            while(d[l]>p){l++;}
            while(d[r]<p){r--;}
            if(l<=r){
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            }
            _sortInt(d, left, r);
            _sortInt(d, l, right);
        }
    } if(left>=right){return;} left>=right left right {return;} return; int p = d[(left+right)/2]; p d[(left+right)/2] d (left+right)/2 (left+right) left right 2 int l=left l left r=right r right tmp; tmp while(l<r){
            while(d[l]>p){l++;}
            while(d[r]<p){r--;}
            if(l<=r){
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            }
            _sortInt(d, left, r);
            _sortInt(d, l, right);
        } l<r l r {
            while(d[l]>p){l++;}
            while(d[r]<p){r--;}
            if(l<=r){
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            }
            _sortInt(d, left, r);
            _sortInt(d, l, right);
        } while(d[l]>p){l++;} d[l]>p d[l] d l p {l++;} l++ l while(d[r]<p){r--;} d[r]<p d[r] d r p {r--;} r-- r if(l<=r){
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            } l<=r l r {
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            } tmp = d[l] tmp d[l] d l d[l] = d[r] d[l] d l d[r] d r d[r] = tmp d[r] d r tmp l++ l r-- r _sortInt(d, left, r) _sortInt d left r _sortInt(d, l, right) _sortInt d l right int[] d d int left left int right right public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] arg = new int[n];
        for(int i=0;i<n;i++){
            arg[i] = Integer.parseInt(sc.next());
        }
        _sortInt(arg, 0, n-1);
        int asum=0, bsum=0;
        for(int i=0;i<n;i++){
            if(i%2==0){
                asum += arg[i];
            }else{
                bsum += arg[i];
            }
        }
        System.out.println(asum - bsum);
    }

    // 降順クイックソート
    private static void _sortInt(int[] d, int left, int right){
        if(left>=right){return;}
        int p = d[(left+right)/2];
        int l=left, r=right, tmp;
        while(l<r){
            while(d[l]>p){l++;}
            while(d[r]<p){r--;}
            if(l<=r){
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            }
            _sortInt(d, left, r);
            _sortInt(d, l, right);
        }
    }
} public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] arg = new int[n];
        for(int i=0;i<n;i++){
            arg[i] = Integer.parseInt(sc.next());
        }
        _sortInt(arg, 0, n-1);
        int asum=0, bsum=0;
        for(int i=0;i<n;i++){
            if(i%2==0){
                asum += arg[i];
            }else{
                bsum += arg[i];
            }
        }
        System.out.println(asum - bsum);
    }

    // 降順クイックソート
    private static void _sortInt(int[] d, int left, int right){
        if(left>=right){return;}
        int p = d[(left+right)/2];
        int l=left, r=right, tmp;
        while(l<r){
            while(d[l]>p){l++;}
            while(d[r]<p){r--;}
            if(l<=r){
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            }
            _sortInt(d, left, r);
            _sortInt(d, l, right);
        }
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] arg = new int[n];
        for(int i=0;i<n;i++){
            arg[i] = Integer.parseInt(sc.next());
        }
        _sortInt(arg, 0, n-1);
        int asum=0, bsum=0;
        for(int i=0;i<n;i++){
            if(i%2==0){
                asum += arg[i];
            }else{
                bsum += arg[i];
            }
        }
        System.out.println(asum - bsum);
    }

    // 降順クイックソート
    private static void _sortInt(int[] d, int left, int right){
        if(left>=right){return;}
        int p = d[(left+right)/2];
        int l=left, r=right, tmp;
        while(l<r){
            while(d[l]>p){l++;}
            while(d[r]<p){r--;}
            if(l<=r){
                tmp = d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            }
            _sortInt(d, left, r);
            _sortInt(d, l, right);
        }
    }
}