import java.util.*;
 
class Main {
  
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer card[] = new Integer[N];
        int Alice = 0;
        int Bob = 0;
      
      for(int i=0;i<N;i++){
        card[i] = Integer.parseInt(sc.next());
      }
		Arrays.sort(card, Collections.reverseOrder());
      
      for(int i = 0;i<N;i++){
        if(i%2==0){Alice +=card[i];}
        else{Bob +=card[i];}
      }

		System.out.print(Alice-Bob);
    }
} import java.util.*; util.* java class Main {
  
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer card[] = new Integer[N];
        int Alice = 0;
        int Bob = 0;
      
      for(int i=0;i<N;i++){
        card[i] = Integer.parseInt(sc.next());
      }
		Arrays.sort(card, Collections.reverseOrder());
      
      for(int i = 0;i<N;i++){
        if(i%2==0){Alice +=card[i];}
        else{Bob +=card[i];}
      }

		System.out.print(Alice-Bob);
    }
} Main public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer card[] = new Integer[N];
        int Alice = 0;
        int Bob = 0;
      
      for(int i=0;i<N;i++){
        card[i] = Integer.parseInt(sc.next());
      }
		Arrays.sort(card, Collections.reverseOrder());
      
      for(int i = 0;i<N;i++){
        if(i%2==0){Alice +=card[i];}
        else{Bob +=card[i];}
      }

		System.out.print(Alice-Bob);
    } main {
      
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer card[] = new Integer[N];
        int Alice = 0;
        int Bob = 0;
      
      for(int i=0;i<N;i++){
        card[i] = Integer.parseInt(sc.next());
      }
		Arrays.sort(card, Collections.reverseOrder());
      
      for(int i = 0;i<N;i++){
        if(i%2==0){Alice +=card[i];}
        else{Bob +=card[i];}
      }

		System.out.print(Alice-Bob);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Integer card[] = new Integer[N]; card new Integer[N] N int Alice = 0; Alice 0 int Bob = 0; Bob 0 for(int i=0;i<N;i++){
        card[i] = Integer.parseInt(sc.next());
      } int i=0; int i=0; i 0 i<N i N i++ i++ i {
        card[i] = Integer.parseInt(sc.next());
      } {
        card[i] = Integer.parseInt(sc.next());
      } card[i] = Integer.parseInt(sc.next()) card[i] card i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(card, Collections.reverseOrder()) Arrays.sort Arrays card Collections.reverseOrder() Collections.reverseOrder Collections for(int i = 0;i<N;i++){
        if(i%2==0){Alice +=card[i];}
        else{Bob +=card[i];}
      } int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
        if(i%2==0){Alice +=card[i];}
        else{Bob +=card[i];}
      } {
        if(i%2==0){Alice +=card[i];}
        else{Bob +=card[i];}
      } if(i%2==0){Alice +=card[i];}
        else{Bob +=card[i];} i%2==0 i%2 i 2 0 {Alice +=card[i];} Alice +=card[i] Alice card[i] card i {Bob +=card[i];} Bob +=card[i] Bob card[i] card i System.out.print(Alice-Bob) System.out.print System.out System System.out Alice-Bob Alice Bob String[] args args
import java.util.*;
 
class Main {
  
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer card[] = new Integer[N];
        int Alice = 0;
        int Bob = 0;
      
      for(int i=0;i<N;i++){
        card[i] = Integer.parseInt(sc.next());
      }
		Arrays.sort(card, Collections.reverseOrder());
      
      for(int i = 0;i<N;i++){
        if(i%2==0){Alice +=card[i];}
        else{Bob +=card[i];}
      }

		System.out.print(Alice-Bob);
    }
}