import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=0;
		int B=0;

		int n = sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		for(int i=0;n>i;i++) {
			int b=sc.nextInt();
			list.add(b);
		}
		//System.out.println(list);
        Collections.sort(list, Collections.reverseOrder());
        //System.out.println(list);

        for(int i=0;n>i;i++) {
        	if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	}
        }
        System.out.println(A-B);
	}

} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List 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 A=0;
		int B=0;

		int n = sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		for(int i=0;n>i;i++) {
			int b=sc.nextInt();
			list.add(b);
		}
		//System.out.println(list);
        Collections.sort(list, Collections.reverseOrder());
        //System.out.println(list);

        for(int i=0;n>i;i++) {
        	if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	}
        }
        System.out.println(A-B);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=0;
		int B=0;

		int n = sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		for(int i=0;n>i;i++) {
			int b=sc.nextInt();
			list.add(b);
		}
		//System.out.println(list);
        Collections.sort(list, Collections.reverseOrder());
        //System.out.println(list);

        for(int i=0;n>i;i++) {
        	if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	}
        }
        System.out.println(A-B);
	} main {
		Scanner sc = new Scanner(System.in);
		int A=0;
		int B=0;

		int n = sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		for(int i=0;n>i;i++) {
			int b=sc.nextInt();
			list.add(b);
		}
		//System.out.println(list);
        Collections.sort(list, Collections.reverseOrder());
        //System.out.println(list);

        for(int i=0;n>i;i++) {
        	if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	}
        }
        System.out.println(A-B);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A=0; A 0 int B=0; B 0 int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc List<Integer> list=new ArrayList<Integer>(); list new ArrayList<Integer>() for(int i=0;n>i;i++) {
			int b=sc.nextInt();
			list.add(b);
		} int i=0; int i=0; i 0 n>i n i i++ i++ i {
			int b=sc.nextInt();
			list.add(b);
		} {
			int b=sc.nextInt();
			list.add(b);
		} int b=sc.nextInt(); b sc.nextInt() sc.nextInt sc list.add(b) list.add list b Collections.sort(list, Collections.reverseOrder()) Collections.sort Collections list Collections.reverseOrder() Collections.reverseOrder Collections for(int i=0;n>i;i++) {
        	if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	}
        } int i=0; int i=0; i 0 n>i n i i++ i++ i {
        	if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	}
        } {
        	if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	}
        } if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	} i%2==0 i%2 i 2 0 {
        		A=A+list.get(i);
        	} A=A+list.get(i) A A+list.get(i) A list.get(i) list.get list i {
        		B=B+list.get(i);
        	} B=B+list.get(i) B B+list.get(i) B list.get(i) list.get list i 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 sc = new Scanner(System.in);
		int A=0;
		int B=0;

		int n = sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		for(int i=0;n>i;i++) {
			int b=sc.nextInt();
			list.add(b);
		}
		//System.out.println(list);
        Collections.sort(list, Collections.reverseOrder());
        //System.out.println(list);

        for(int i=0;n>i;i++) {
        	if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	}
        }
        System.out.println(A-B);
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=0;
		int B=0;

		int n = sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		for(int i=0;n>i;i++) {
			int b=sc.nextInt();
			list.add(b);
		}
		//System.out.println(list);
        Collections.sort(list, Collections.reverseOrder());
        //System.out.println(list);

        for(int i=0;n>i;i++) {
        	if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	}
        }
        System.out.println(A-B);
	}

} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=0;
		int B=0;

		int n = sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		for(int i=0;n>i;i++) {
			int b=sc.nextInt();
			list.add(b);
		}
		//System.out.println(list);
        Collections.sort(list, Collections.reverseOrder());
        //System.out.println(list);

        for(int i=0;n>i;i++) {
        	if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	}
        }
        System.out.println(A-B);
	}

}
