import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for(int i = 0 ; i < n ; i ++){
          array[i] = sc.nextInt();
        }
      	Arrays.sort(array);
        int a = 0 ;
        int b = 0 ;
      	
      	for(int i = 1 ; i <= n ; i ++){
          if(i % 2 != 0){
          	a += array[n-i];
          }else{
          	b += array[n-i];
          }
        }
       System.out.print(a-b);
      
    }
}

 import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for(int i = 0 ; i < n ; i ++){
          array[i] = sc.nextInt();
        }
      	Arrays.sort(array);
        int a = 0 ;
        int b = 0 ;
      	
      	for(int i = 1 ; i <= n ; i ++){
          if(i % 2 != 0){
          	a += array[n-i];
          }else{
          	b += array[n-i];
          }
        }
       System.out.print(a-b);
      
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for(int i = 0 ; i < n ; i ++){
          array[i] = sc.nextInt();
        }
      	Arrays.sort(array);
        int a = 0 ;
        int b = 0 ;
      	
      	for(int i = 1 ; i <= n ; i ++){
          if(i % 2 != 0){
          	a += array[n-i];
          }else{
          	b += array[n-i];
          }
        }
       System.out.print(a-b);
      
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for(int i = 0 ; i < n ; i ++){
          array[i] = sc.nextInt();
        }
      	Arrays.sort(array);
        int a = 0 ;
        int b = 0 ;
      	
      	for(int i = 1 ; i <= n ; i ++){
          if(i % 2 != 0){
          	a += array[n-i];
          }else{
          	b += array[n-i];
          }
        }
       System.out.print(a-b);
      
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] array = new int[n]; array new int[n] n for(int i = 0 ; i < n ; i ++){
          array[i] = sc.nextInt();
        } int i = 0 ; int i = 0 ; i 0 i < n i n 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 int a = 0 ; a 0 int b = 0 ; b 0 for(int i = 1 ; i <= n ; i ++){
          if(i % 2 != 0){
          	a += array[n-i];
          }else{
          	b += array[n-i];
          }
        } int i = 1 ; int i = 1 ; i 1 i <= n i n i ++ i ++ i {
          if(i % 2 != 0){
          	a += array[n-i];
          }else{
          	b += array[n-i];
          }
        } {
          if(i % 2 != 0){
          	a += array[n-i];
          }else{
          	b += array[n-i];
          }
        } if(i % 2 != 0){
          	a += array[n-i];
          }else{
          	b += array[n-i];
          } i % 2 != 0 i % 2 i 2 0 {
          	a += array[n-i];
          } a += array[n-i] a array[n-i] array n-i n i {
          	b += array[n-i];
          } b += array[n-i] b array[n-i] array n-i n i System.out.print(a-b) System.out.print System.out System System.out a-b a b String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for(int i = 0 ; i < n ; i ++){
          array[i] = sc.nextInt();
        }
      	Arrays.sort(array);
        int a = 0 ;
        int b = 0 ;
      	
      	for(int i = 1 ; i <= n ; i ++){
          if(i % 2 != 0){
          	a += array[n-i];
          }else{
          	b += array[n-i];
          }
        }
       System.out.print(a-b);
      
    }
}


