import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int bob=0;
		int Alice=0;
		int b[]=new int[a];
		for(int i=0;i!=a;i++) {
			b[i]=scan.nextInt();
		}
		Arrays.sort(b);
		for(int i=0;i!=a;i++) {
			if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			}
		}
		System.out.println(Math.abs(Alice-bob));
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int bob=0;
		int Alice=0;
		int b[]=new int[a];
		for(int i=0;i!=a;i++) {
			b[i]=scan.nextInt();
		}
		Arrays.sort(b);
		for(int i=0;i!=a;i++) {
			if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			}
		}
		System.out.println(Math.abs(Alice-bob));
	}
} Main public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int bob=0;
		int Alice=0;
		int b[]=new int[a];
		for(int i=0;i!=a;i++) {
			b[i]=scan.nextInt();
		}
		Arrays.sort(b);
		for(int i=0;i!=a;i++) {
			if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			}
		}
		System.out.println(Math.abs(Alice-bob));
	} main {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int bob=0;
		int Alice=0;
		int b[]=new int[a];
		for(int i=0;i!=a;i++) {
			b[i]=scan.nextInt();
		}
		Arrays.sort(b);
		for(int i=0;i!=a;i++) {
			if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			}
		}
		System.out.println(Math.abs(Alice-bob));
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int a=scan.nextInt(); a scan.nextInt() scan.nextInt scan int bob=0; bob 0 int Alice=0; Alice 0 int b[]=new int[a]; b new int[a] a for(int i=0;i!=a;i++) {
			b[i]=scan.nextInt();
		} int i=0; int i=0; i 0 i!=a i a i++ i++ i {
			b[i]=scan.nextInt();
		} {
			b[i]=scan.nextInt();
		} b[i]=scan.nextInt() b[i] b i scan.nextInt() scan.nextInt scan Arrays.sort(b) Arrays.sort Arrays b for(int i=0;i!=a;i++) {
			if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			}
		} int i=0; int i=0; i 0 i!=a i a i++ i++ i {
			if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			}
		} {
			if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			}
		} if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			} i%2==0 i%2 i 2 0 {
				bob+=b[i];
			} bob+=b[i] bob b[i] b i {
				Alice+=b[i];
			} Alice+=b[i] Alice b[i] b i System.out.println(Math.abs(Alice-bob)) System.out.println System.out System System.out Math.abs(Alice-bob) Math.abs Math Alice-bob Alice bob String[] args args public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int bob=0;
		int Alice=0;
		int b[]=new int[a];
		for(int i=0;i!=a;i++) {
			b[i]=scan.nextInt();
		}
		Arrays.sort(b);
		for(int i=0;i!=a;i++) {
			if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			}
		}
		System.out.println(Math.abs(Alice-bob));
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int bob=0;
		int Alice=0;
		int b[]=new int[a];
		for(int i=0;i!=a;i++) {
			b[i]=scan.nextInt();
		}
		Arrays.sort(b);
		for(int i=0;i!=a;i++) {
			if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			}
		}
		System.out.println(Math.abs(Alice-bob));
	}
} Main
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int bob=0;
		int Alice=0;
		int b[]=new int[a];
		for(int i=0;i!=a;i++) {
			b[i]=scan.nextInt();
		}
		Arrays.sort(b);
		for(int i=0;i!=a;i++) {
			if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			}
		}
		System.out.println(Math.abs(Alice-bob));
	}
}