import java.util.*;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = Integer.parseInt(sc.next());
    	Integer a[] = new Integer[N];

    	for (int i=0; i<N; i++){
    		a[i] = Integer.parseInt(sc.next());
    	}

    	Arrays.sort(a, Collections.reverseOrder());

    	int ans = 0;

    	for(int i=0; i<N; i++){
    		if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		}
    	}

    	System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = Integer.parseInt(sc.next());
    	Integer a[] = new Integer[N];

    	for (int i=0; i<N; i++){
    		a[i] = Integer.parseInt(sc.next());
    	}

    	Arrays.sort(a, Collections.reverseOrder());

    	int ans = 0;

    	for(int i=0; i<N; i++){
    		if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		}
    	}

    	System.out.println(ans);
    }
} Main public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = Integer.parseInt(sc.next());
    	Integer a[] = new Integer[N];

    	for (int i=0; i<N; i++){
    		a[i] = Integer.parseInt(sc.next());
    	}

    	Arrays.sort(a, Collections.reverseOrder());

    	int ans = 0;

    	for(int i=0; i<N; i++){
    		if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		}
    	}

    	System.out.println(ans);
    } main {
    	Scanner sc = new Scanner(System.in);
    	int N = Integer.parseInt(sc.next());
    	Integer a[] = new Integer[N];

    	for (int i=0; i<N; i++){
    		a[i] = Integer.parseInt(sc.next());
    	}

    	Arrays.sort(a, Collections.reverseOrder());

    	int ans = 0;

    	for(int i=0; i<N; i++){
    		if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		}
    	}

    	System.out.println(ans);
    } 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 Integer a[] = new Integer[N]; a new Integer[N] N for (int i=0; i<N; i++){
    		a[i] = Integer.parseInt(sc.next());
    	} int i=0; int i=0; i 0 i<N i N i++ i++ i {
    		a[i] = Integer.parseInt(sc.next());
    	} {
    		a[i] = Integer.parseInt(sc.next());
    	} a[i] = Integer.parseInt(sc.next()) a[i] a i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(a, Collections.reverseOrder()) Arrays.sort Arrays a Collections.reverseOrder() Collections.reverseOrder Collections int ans = 0; ans 0 for(int i=0; i<N; i++){
    		if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		}
    	} int i=0; int i=0; i 0 i<N i N i++ i++ i {
    		if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		}
    	} {
    		if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		}
    	} if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		} i%2==0 i%2 i 2 0 {
    			ans += a[i];
    		} ans += a[i] ans a[i] a i {
    			ans -= a[i];
    		} ans -= a[i] ans a[i] a i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = Integer.parseInt(sc.next());
    	Integer a[] = new Integer[N];

    	for (int i=0; i<N; i++){
    		a[i] = Integer.parseInt(sc.next());
    	}

    	Arrays.sort(a, Collections.reverseOrder());

    	int ans = 0;

    	for(int i=0; i<N; i++){
    		if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		}
    	}

    	System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = Integer.parseInt(sc.next());
    	Integer a[] = new Integer[N];

    	for (int i=0; i<N; i++){
    		a[i] = Integer.parseInt(sc.next());
    	}

    	Arrays.sort(a, Collections.reverseOrder());

    	int ans = 0;

    	for(int i=0; i<N; i++){
    		if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		}
    	}

    	System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = Integer.parseInt(sc.next());
    	Integer a[] = new Integer[N];

    	for (int i=0; i<N; i++){
    		a[i] = Integer.parseInt(sc.next());
    	}

    	Arrays.sort(a, Collections.reverseOrder());

    	int ans = 0;

    	for(int i=0; i<N; i++){
    		if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		}
    	}

    	System.out.println(ans);
    }
}