import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] cards = new int[N];
		for(int i=0;i<N;i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int sum=0;
		for(int j=N;j>1;j=j-2) {
			sum += cards[j-1] -cards[j -2];
		}
		if(N % 2 == 1)sum+=cards[0];
		
		System.out.println(sum);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

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

		int N = sc.nextInt();

		int[] cards = new int[N];
		for(int i=0;i<N;i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int sum=0;
		for(int j=N;j>1;j=j-2) {
			sum += cards[j-1] -cards[j -2];
		}
		if(N % 2 == 1)sum+=cards[0];
		
		System.out.println(sum);
	} main {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] cards = new int[N];
		for(int i=0;i<N;i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int sum=0;
		for(int j=N;j>1;j=j-2) {
			sum += cards[j-1] -cards[j -2];
		}
		if(N % 2 == 1)sum+=cards[0];
		
		System.out.println(sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] cards = new int[N]; cards new int[N] N for(int i=0;i<N;i++) {
			cards[i] = sc.nextInt();
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			cards[i] = sc.nextInt();
		} {
			cards[i] = sc.nextInt();
		} cards[i] = sc.nextInt() cards[i] cards i sc.nextInt() sc.nextInt sc Arrays.sort(cards) Arrays.sort Arrays cards int sum=0; sum 0 for(int j=N;j>1;j=j-2) {
			sum += cards[j-1] -cards[j -2];
		} int j=N; int j=N; j N j>1 j 1 j=j-2 j=j-2 j j-2 j 2 {
			sum += cards[j-1] -cards[j -2];
		} {
			sum += cards[j-1] -cards[j -2];
		} sum += cards[j-1] -cards[j -2] sum cards[j-1] -cards[j -2] cards[j-1] cards j-1 j 1 cards[j -2] cards j -2 j 2 if(N % 2 == 1)sum+=cards[0]; N % 2 == 1 N % 2 N 2 1 sum+=cards[0] sum cards[0] cards 0 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] cards = new int[N];
		for(int i=0;i<N;i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int sum=0;
		for(int j=N;j>1;j=j-2) {
			sum += cards[j-1] -cards[j -2];
		}
		if(N % 2 == 1)sum+=cards[0];
		
		System.out.println(sum);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] cards = new int[N];
		for(int i=0;i<N;i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int sum=0;
		for(int j=N;j>1;j=j-2) {
			sum += cards[j-1] -cards[j -2];
		}
		if(N % 2 == 1)sum+=cards[0];
		
		System.out.println(sum);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] cards = new int[N];
		for(int i=0;i<N;i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int sum=0;
		for(int j=N;j>1;j=j-2) {
			sum += cards[j-1] -cards[j -2];
		}
		if(N % 2 == 1)sum+=cards[0];
		
		System.out.println(sum);
	}
}
