import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = 0, b = 0;
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			list.add(scan.nextInt());
		}
		if(n%2==1)list.add(0);
		
		Collections.sort(list, Collections.reverseOrder());
		for(int i = 0; i < list.size(); i += 2){
			a += list.get(i);
			b += list.get(i+1);
		}
		
		System.out.println(a - b);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = 0, b = 0;
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			list.add(scan.nextInt());
		}
		if(n%2==1)list.add(0);
		
		Collections.sort(list, Collections.reverseOrder());
		for(int i = 0; i < list.size(); i += 2){
			a += list.get(i);
			b += list.get(i+1);
		}
		
		System.out.println(a - b);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = 0, b = 0;
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			list.add(scan.nextInt());
		}
		if(n%2==1)list.add(0);
		
		Collections.sort(list, Collections.reverseOrder());
		for(int i = 0; i < list.size(); i += 2){
			a += list.get(i);
			b += list.get(i+1);
		}
		
		System.out.println(a - b);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = 0, b = 0;
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			list.add(scan.nextInt());
		}
		if(n%2==1)list.add(0);
		
		Collections.sort(list, Collections.reverseOrder());
		for(int i = 0; i < list.size(); i += 2){
			a += list.get(i);
			b += list.get(i+1);
		}
		
		System.out.println(a - b);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int a = 0 a 0 b = 0; b 0 List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for(int i = 0; i < n; i++){
			list.add(scan.nextInt());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			list.add(scan.nextInt());
		} {
			list.add(scan.nextInt());
		} list.add(scan.nextInt()) list.add list scan.nextInt() scan.nextInt scan if(n%2==1)list.add(0); n%2==1 n%2 n 2 1 list.add(0) list.add list 0 Collections.sort(list, Collections.reverseOrder()) Collections.sort Collections list Collections.reverseOrder() Collections.reverseOrder Collections for(int i = 0; i < list.size(); i += 2){
			a += list.get(i);
			b += list.get(i+1);
		} int i = 0; int i = 0; i 0 i < list.size() i list.size() list.size list i += 2 i += 2 i 2 {
			a += list.get(i);
			b += list.get(i+1);
		} {
			a += list.get(i);
			b += list.get(i+1);
		} a += list.get(i) a list.get(i) list.get list i b += list.get(i+1) b list.get(i+1) list.get list i+1 i 1 System.out.println(a - b) System.out.println System.out System System.out a - b a b String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = 0, b = 0;
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			list.add(scan.nextInt());
		}
		if(n%2==1)list.add(0);
		
		Collections.sort(list, Collections.reverseOrder());
		for(int i = 0; i < list.size(); i += 2){
			a += list.get(i);
			b += list.get(i+1);
		}
		
		System.out.println(a - b);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = 0, b = 0;
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			list.add(scan.nextInt());
		}
		if(n%2==1)list.add(0);
		
		Collections.sort(list, Collections.reverseOrder());
		for(int i = 0; i < list.size(); i += 2){
			a += list.get(i);
			b += list.get(i+1);
		}
		
		System.out.println(a - b);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = 0, b = 0;
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			list.add(scan.nextInt());
		}
		if(n%2==1)list.add(0);
		
		Collections.sort(list, Collections.reverseOrder());
		for(int i = 0; i < list.size(); i += 2){
			a += list.get(i);
			b += list.get(i+1);
		}
		
		System.out.println(a - b);
	}
}