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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt();
		//int x=sc.nextInt();//,k=sc.nextInt();
		long sum=0,count=0,flag=0,max=-999999,min=99999;
		long[] array=new long[a];
		//String s=sc.next();//,t=sc.next();
		String buff;
		//String[] arrays = new String[a];
		for(int i=0;i<a;i++) {
			array[i]=sc.nextInt();
		}
		Arrays.sort(array);
		for(int i=a-1;i>=0;i-=2) {
			sum+=array[i];
			if(i-1<0)break;
			count+=array[i-1];
		}

		System.out.println(sum-count);

	}
	public static int sample(int n) {
		return n;
	}

} 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 a = sc.nextInt();//, b = sc.nextInt();
		//int x=sc.nextInt();//,k=sc.nextInt();
		long sum=0,count=0,flag=0,max=-999999,min=99999;
		long[] array=new long[a];
		//String s=sc.next();//,t=sc.next();
		String buff;
		//String[] arrays = new String[a];
		for(int i=0;i<a;i++) {
			array[i]=sc.nextInt();
		}
		Arrays.sort(array);
		for(int i=a-1;i>=0;i-=2) {
			sum+=array[i];
			if(i-1<0)break;
			count+=array[i-1];
		}

		System.out.println(sum-count);

	}
	public static int sample(int n) {
		return n;
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt();
		//int x=sc.nextInt();//,k=sc.nextInt();
		long sum=0,count=0,flag=0,max=-999999,min=99999;
		long[] array=new long[a];
		//String s=sc.next();//,t=sc.next();
		String buff;
		//String[] arrays = new String[a];
		for(int i=0;i<a;i++) {
			array[i]=sc.nextInt();
		}
		Arrays.sort(array);
		for(int i=a-1;i>=0;i-=2) {
			sum+=array[i];
			if(i-1<0)break;
			count+=array[i-1];
		}

		System.out.println(sum-count);

	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt();
		//int x=sc.nextInt();//,k=sc.nextInt();
		long sum=0,count=0,flag=0,max=-999999,min=99999;
		long[] array=new long[a];
		//String s=sc.next();//,t=sc.next();
		String buff;
		//String[] arrays = new String[a];
		for(int i=0;i<a;i++) {
			array[i]=sc.nextInt();
		}
		Arrays.sort(array);
		for(int i=a-1;i>=0;i-=2) {
			sum+=array[i];
			if(i-1<0)break;
			count+=array[i-1];
		}

		System.out.println(sum-count);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc long sum=0 sum 0 count=0 count 0 flag=0 flag 0 max=-999999 max -999999 999999 min=99999; min 99999 long[] array=new long[a]; array new long[a] a String buff; buff for(int i=0;i<a;i++) {
			array[i]=sc.nextInt();
		} int i=0; int i=0; i 0 i<a i a i++ i++ i {
			array[i]=sc.nextInt();
		} {
			array[i]=sc.nextInt();
		} array[i]=sc.nextInt() array[i] array i sc.nextInt() sc.nextInt sc Arrays.sort(array) Arrays.sort Arrays array for(int i=a-1;i>=0;i-=2) {
			sum+=array[i];
			if(i-1<0)break;
			count+=array[i-1];
		} int i=a-1; int i=a-1; i a-1 a 1 i>=0 i 0 i-=2 i-=2 i 2 {
			sum+=array[i];
			if(i-1<0)break;
			count+=array[i-1];
		} {
			sum+=array[i];
			if(i-1<0)break;
			count+=array[i-1];
		} sum+=array[i] sum array[i] array i if(i-1<0)break; i-1<0 i-1 i 1 0 break; count+=array[i-1] count array[i-1] array i-1 i 1 System.out.println(sum-count) System.out.println System.out System System.out sum-count sum count String[] args args public static int sample(int n) {
		return n;
	} sample {
		return n;
	} return n; n int n n public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt();
		//int x=sc.nextInt();//,k=sc.nextInt();
		long sum=0,count=0,flag=0,max=-999999,min=99999;
		long[] array=new long[a];
		//String s=sc.next();//,t=sc.next();
		String buff;
		//String[] arrays = new String[a];
		for(int i=0;i<a;i++) {
			array[i]=sc.nextInt();
		}
		Arrays.sort(array);
		for(int i=a-1;i>=0;i-=2) {
			sum+=array[i];
			if(i-1<0)break;
			count+=array[i-1];
		}

		System.out.println(sum-count);

	}
	public static int sample(int n) {
		return n;
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt();
		//int x=sc.nextInt();//,k=sc.nextInt();
		long sum=0,count=0,flag=0,max=-999999,min=99999;
		long[] array=new long[a];
		//String s=sc.next();//,t=sc.next();
		String buff;
		//String[] arrays = new String[a];
		for(int i=0;i<a;i++) {
			array[i]=sc.nextInt();
		}
		Arrays.sort(array);
		for(int i=a-1;i>=0;i-=2) {
			sum+=array[i];
			if(i-1<0)break;
			count+=array[i-1];
		}

		System.out.println(sum-count);

	}
	public static int sample(int n) {
		return n;
	}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt();
		//int x=sc.nextInt();//,k=sc.nextInt();
		long sum=0,count=0,flag=0,max=-999999,min=99999;
		long[] array=new long[a];
		//String s=sc.next();//,t=sc.next();
		String buff;
		//String[] arrays = new String[a];
		for(int i=0;i<a;i++) {
			array[i]=sc.nextInt();
		}
		Arrays.sort(array);
		for(int i=a-1;i>=0;i-=2) {
			sum+=array[i];
			if(i-1<0)break;
			count+=array[i-1];
		}

		System.out.println(sum-count);

	}
	public static int sample(int n) {
		return n;
	}

}
