import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for(int i=0; i<n; i++){
			list.add(sc.nextInt());
		}
		list.sort(Comparator.reverseOrder());
		int alice = 0, bob = 0;
		for(int i=0; i<n; i++){
			if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(i);
			}
		}
		System.out.println(alice - bob);
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for(int i=0; i<n; i++){
			list.add(sc.nextInt());
		}
		list.sort(Comparator.reverseOrder());
		int alice = 0, bob = 0;
		for(int i=0; i<n; i++){
			if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(i);
			}
		}
		System.out.println(alice - bob);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for(int i=0; i<n; i++){
			list.add(sc.nextInt());
		}
		list.sort(Comparator.reverseOrder());
		int alice = 0, bob = 0;
		for(int i=0; i<n; i++){
			if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(i);
			}
		}
		System.out.println(alice - bob);
	} main {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for(int i=0; i<n; i++){
			list.add(sc.nextInt());
		}
		list.sort(Comparator.reverseOrder());
		int alice = 0, bob = 0;
		for(int i=0; i<n; i++){
			if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(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 List<Integer> list = new ArrayList<>(); list new ArrayList<>() for(int i=0; i<n; i++){
			list.add(sc.nextInt());
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			list.add(sc.nextInt());
		} {
			list.add(sc.nextInt());
		} list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc list.sort(Comparator.reverseOrder()) list.sort list Comparator.reverseOrder() Comparator.reverseOrder Comparator int alice = 0 alice 0 bob = 0; bob 0 for(int i=0; i<n; i++){
			if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(i);
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(i);
			}
		} {
			if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(i);
			}
		} if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(i);
			} i % 2 == 0 i % 2 i 2 0 {
				alice += list.get(i);
			} alice += list.get(i) alice list.get(i) list.get list i {
				bob += list.get(i);
			} bob += list.get(i) bob list.get(i) list.get list 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();
		List<Integer> list = new ArrayList<>();
		for(int i=0; i<n; i++){
			list.add(sc.nextInt());
		}
		list.sort(Comparator.reverseOrder());
		int alice = 0, bob = 0;
		for(int i=0; i<n; i++){
			if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(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();
		List<Integer> list = new ArrayList<>();
		for(int i=0; i<n; i++){
			list.add(sc.nextInt());
		}
		list.sort(Comparator.reverseOrder());
		int alice = 0, bob = 0;
		for(int i=0; i<n; i++){
			if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(i);
			}
		}
		System.out.println(alice - bob);
	}
} Main
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for(int i=0; i<n; i++){
			list.add(sc.nextInt());
		}
		list.sort(Comparator.reverseOrder());
		int alice = 0, bob = 0;
		for(int i=0; i<n; i++){
			if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(i);
			}
		}
		System.out.println(alice - bob);
	}
}
