import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int n = scan.nextInt();
	    int a[]=new int[n];
	    for(int i=0;i<n;i++) {
	    	a[i]=scan.nextInt();
	    }
	    scan.close();
	    Arrays.sort(a);
	    int Acnt=0,Bcnt=0;
	    for(int i=n-1,j=0;i>=0;i--,j++) {
	    	if(j%2==0)Acnt+=a[i];
	    	else Bcnt+=a[i];
	    }
	    System.out.println(Acnt-Bcnt);
	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int n = scan.nextInt();
	    int a[]=new int[n];
	    for(int i=0;i<n;i++) {
	    	a[i]=scan.nextInt();
	    }
	    scan.close();
	    Arrays.sort(a);
	    int Acnt=0,Bcnt=0;
	    for(int i=n-1,j=0;i>=0;i--,j++) {
	    	if(j%2==0)Acnt+=a[i];
	    	else Bcnt+=a[i];
	    }
	    System.out.println(Acnt-Bcnt);
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int n = scan.nextInt();
	    int a[]=new int[n];
	    for(int i=0;i<n;i++) {
	    	a[i]=scan.nextInt();
	    }
	    scan.close();
	    Arrays.sort(a);
	    int Acnt=0,Bcnt=0;
	    for(int i=n-1,j=0;i>=0;i--,j++) {
	    	if(j%2==0)Acnt+=a[i];
	    	else Bcnt+=a[i];
	    }
	    System.out.println(Acnt-Bcnt);
	} main {
		Scanner scan = new Scanner(System.in);
	    int n = scan.nextInt();
	    int a[]=new int[n];
	    for(int i=0;i<n;i++) {
	    	a[i]=scan.nextInt();
	    }
	    scan.close();
	    Arrays.sort(a);
	    int Acnt=0,Bcnt=0;
	    for(int i=n-1,j=0;i>=0;i--,j++) {
	    	if(j%2==0)Acnt+=a[i];
	    	else Bcnt+=a[i];
	    }
	    System.out.println(Acnt-Bcnt);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int a[]=new int[n]; a new int[n] n for(int i=0;i<n;i++) {
	    	a[i]=scan.nextInt();
	    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
	    	a[i]=scan.nextInt();
	    } {
	    	a[i]=scan.nextInt();
	    } a[i]=scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan scan.close() scan.close scan Arrays.sort(a) Arrays.sort Arrays a int Acnt=0 Acnt 0 Bcnt=0; Bcnt 0 for(int i=n-1,j=0;i>=0;i--,j++) {
	    	if(j%2==0)Acnt+=a[i];
	    	else Bcnt+=a[i];
	    } int i=n-1,j=0; int i=n-1 i n-1 n 1 j=0; j 0 i>=0 i 0 i--,j++ i-- i j++ j {
	    	if(j%2==0)Acnt+=a[i];
	    	else Bcnt+=a[i];
	    } {
	    	if(j%2==0)Acnt+=a[i];
	    	else Bcnt+=a[i];
	    } if(j%2==0)Acnt+=a[i];
	    	else Bcnt+=a[i]; j%2==0 j%2 j 2 0 Acnt+=a[i] Acnt a[i] a i Bcnt+=a[i] Bcnt a[i] a i System.out.println(Acnt-Bcnt) System.out.println System.out System System.out Acnt-Bcnt Acnt Bcnt String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int n = scan.nextInt();
	    int a[]=new int[n];
	    for(int i=0;i<n;i++) {
	    	a[i]=scan.nextInt();
	    }
	    scan.close();
	    Arrays.sort(a);
	    int Acnt=0,Bcnt=0;
	    for(int i=n-1,j=0;i>=0;i--,j++) {
	    	if(j%2==0)Acnt+=a[i];
	    	else Bcnt+=a[i];
	    }
	    System.out.println(Acnt-Bcnt);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int n = scan.nextInt();
	    int a[]=new int[n];
	    for(int i=0;i<n;i++) {
	    	a[i]=scan.nextInt();
	    }
	    scan.close();
	    Arrays.sort(a);
	    int Acnt=0,Bcnt=0;
	    for(int i=n-1,j=0;i>=0;i--,j++) {
	    	if(j%2==0)Acnt+=a[i];
	    	else Bcnt+=a[i];
	    }
	    System.out.println(Acnt-Bcnt);
	}

} Main
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int n = scan.nextInt();
	    int a[]=new int[n];
	    for(int i=0;i<n;i++) {
	    	a[i]=scan.nextInt();
	    }
	    scan.close();
	    Arrays.sort(a);
	    int Acnt=0,Bcnt=0;
	    for(int i=n-1,j=0;i>=0;i--,j++) {
	    	if(j%2==0)Acnt+=a[i];
	    	else Bcnt+=a[i];
	    }
	    System.out.println(Acnt-Bcnt);
	}

}