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

    public static void main(String argv[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[]=new int[N];
        for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        }

        Arrays.sort(a);
        int Ali=0;
        int Bob=0;

        for(int i=1; i<=N; i=i+2){
            Ali = Ali+a[N-i];
            if(N-i-1>=0){
                Bob = Bob+a[N-i-1];
            } 
        }
  
        System.out.println(Ali-Bob);

        


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

    public static void main(String argv[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[]=new int[N];
        for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        }

        Arrays.sort(a);
        int Ali=0;
        int Bob=0;

        for(int i=1; i<=N; i=i+2){
            Ali = Ali+a[N-i];
            if(N-i-1>=0){
                Bob = Bob+a[N-i-1];
            } 
        }
  
        System.out.println(Ali-Bob);

        


    }
} Main public static void main(String argv[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[]=new int[N];
        for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        }

        Arrays.sort(a);
        int Ali=0;
        int Bob=0;

        for(int i=1; i<=N; i=i+2){
            Ali = Ali+a[N-i];
            if(N-i-1>=0){
                Bob = Bob+a[N-i-1];
            } 
        }
  
        System.out.println(Ali-Bob);

        


    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[]=new int[N];
        for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        }

        Arrays.sort(a);
        int Ali=0;
        int Bob=0;

        for(int i=1; i<=N; i=i+2){
            Ali = Ali+a[N-i];
            if(N-i-1>=0){
                Bob = Bob+a[N-i-1];
            } 
        }
  
        System.out.println(Ali-Bob);

        


    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int a[]=new int[N]; a new int[N] N for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            a[i]=sc.nextInt();
        } {
            a[i]=sc.nextInt();
        } a[i]=sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc Arrays.sort(a) Arrays.sort Arrays a int Ali=0; Ali 0 int Bob=0; Bob 0 for(int i=1; i<=N; i=i+2){
            Ali = Ali+a[N-i];
            if(N-i-1>=0){
                Bob = Bob+a[N-i-1];
            } 
        } int i=1; int i=1; i 1 i<=N i N i=i+2 i=i+2 i i+2 i 2 {
            Ali = Ali+a[N-i];
            if(N-i-1>=0){
                Bob = Bob+a[N-i-1];
            } 
        } {
            Ali = Ali+a[N-i];
            if(N-i-1>=0){
                Bob = Bob+a[N-i-1];
            } 
        } Ali = Ali+a[N-i] Ali Ali+a[N-i] Ali a[N-i] a N-i N i if(N-i-1>=0){
                Bob = Bob+a[N-i-1];
            } N-i-1>=0 N-i-1 N-i-1 N i 1 0 {
                Bob = Bob+a[N-i-1];
            } Bob = Bob+a[N-i-1] Bob Bob+a[N-i-1] Bob a[N-i-1] a N-i-1 N-i-1 N i 1 System.out.println(Ali-Bob) System.out.println System.out System System.out Ali-Bob Ali Bob String argv[] argv public class Main {

    public static void main(String argv[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[]=new int[N];
        for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        }

        Arrays.sort(a);
        int Ali=0;
        int Bob=0;

        for(int i=1; i<=N; i=i+2){
            Ali = Ali+a[N-i];
            if(N-i-1>=0){
                Bob = Bob+a[N-i-1];
            } 
        }
  
        System.out.println(Ali-Bob);

        


    }
} public class Main {

    public static void main(String argv[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[]=new int[N];
        for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        }

        Arrays.sort(a);
        int Ali=0;
        int Bob=0;

        for(int i=1; i<=N; i=i+2){
            Ali = Ali+a[N-i];
            if(N-i-1>=0){
                Bob = Bob+a[N-i-1];
            } 
        }
  
        System.out.println(Ali-Bob);

        


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

    public static void main(String argv[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[]=new int[N];
        for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        }

        Arrays.sort(a);
        int Ali=0;
        int Bob=0;

        for(int i=1; i<=N; i=i+2){
            Ali = Ali+a[N-i];
            if(N-i-1>=0){
                Bob = Bob+a[N-i-1];
            } 
        }
  
        System.out.println(Ali-Bob);

        


    }
}