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

// 10
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] x = new int[N];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();
        
        Arrays.sort(x);
        int alice = 0;
        int bob = 0;
        if(N % 2 == 0) {
        	for(int i = N - 1; i >= 0; i -= 2) {
        		alice += x[i];
        		bob += x[i - 1];
        	}
        }
        if(N % 2 != 0) {
        	if(N == 1) alice += x[0];
        	else {
				for(int i = 0; i < N; i += 2)
					alice += x[i];
				for(int i = 1; i < N; i += 2)
					bob += x[i];
			}
        }
        
        System.out.println(alice - 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[] x = new int[N];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();
        
        Arrays.sort(x);
        int alice = 0;
        int bob = 0;
        if(N % 2 == 0) {
        	for(int i = N - 1; i >= 0; i -= 2) {
        		alice += x[i];
        		bob += x[i - 1];
        	}
        }
        if(N % 2 != 0) {
        	if(N == 1) alice += x[0];
        	else {
				for(int i = 0; i < N; i += 2)
					alice += x[i];
				for(int i = 1; i < N; i += 2)
					bob += x[i];
			}
        }
        
        System.out.println(alice - bob);
	}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] x = new int[N];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();
        
        Arrays.sort(x);
        int alice = 0;
        int bob = 0;
        if(N % 2 == 0) {
        	for(int i = N - 1; i >= 0; i -= 2) {
        		alice += x[i];
        		bob += x[i - 1];
        	}
        }
        if(N % 2 != 0) {
        	if(N == 1) alice += x[0];
        	else {
				for(int i = 0; i < N; i += 2)
					alice += x[i];
				for(int i = 1; i < N; i += 2)
					bob += x[i];
			}
        }
        
        System.out.println(alice - bob);
	}

} public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] x = new int[N];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();
        
        Arrays.sort(x);
        int alice = 0;
        int bob = 0;
        if(N % 2 == 0) {
        	for(int i = N - 1; i >= 0; i -= 2) {
        		alice += x[i];
        		bob += x[i - 1];
        	}
        }
        if(N % 2 != 0) {
        	if(N == 1) alice += x[0];
        	else {
				for(int i = 0; i < N; i += 2)
					alice += x[i];
				for(int i = 1; i < N; i += 2)
					bob += x[i];
			}
        }
        
        System.out.println(alice - bob);
	}

} Main
import java.util.Arrays;
import java.util.Scanner;

// 10
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] x = new int[N];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();
        
        Arrays.sort(x);
        int alice = 0;
        int bob = 0;
        if(N % 2 == 0) {
        	for(int i = N - 1; i >= 0; i -= 2) {
        		alice += x[i];
        		bob += x[i - 1];
        	}
        }
        if(N % 2 != 0) {
        	if(N == 1) alice += x[0];
        	else {
				for(int i = 0; i < N; i += 2)
					alice += x[i];
				for(int i = 1; i < N; i += 2)
					bob += x[i];
			}
        }
        
        System.out.println(alice - bob);
	}

}
