import java.util.Scanner;
import java.util.Arrays;
public class Main {
  public static void main (String[]args) {
    int Alice_score =0;
    int Bob_score =0;
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ai[] = new int[N];
    
    for(int i = 0; i<N; i++){
      ai[i] = sc.nextInt();
    }
    
    Arrays.sort(ai);


    for(int i = 1; i<=N; i++){
      if(i % 2 != 0){
        Alice_score += ai[N-i];
      } else {
        Bob_score += ai[N-i];
      }
    }

    System.out.println(Alice_score - Bob_score);
  }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {
  public static void main (String[]args) {
    int Alice_score =0;
    int Bob_score =0;
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ai[] = new int[N];
    
    for(int i = 0; i<N; i++){
      ai[i] = sc.nextInt();
    }
    
    Arrays.sort(ai);


    for(int i = 1; i<=N; i++){
      if(i % 2 != 0){
        Alice_score += ai[N-i];
      } else {
        Bob_score += ai[N-i];
      }
    }

    System.out.println(Alice_score - Bob_score);
  }
} Main public static void main (String[]args) {
    int Alice_score =0;
    int Bob_score =0;
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ai[] = new int[N];
    
    for(int i = 0; i<N; i++){
      ai[i] = sc.nextInt();
    }
    
    Arrays.sort(ai);


    for(int i = 1; i<=N; i++){
      if(i % 2 != 0){
        Alice_score += ai[N-i];
      } else {
        Bob_score += ai[N-i];
      }
    }

    System.out.println(Alice_score - Bob_score);
  } main {
    int Alice_score =0;
    int Bob_score =0;
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ai[] = new int[N];
    
    for(int i = 0; i<N; i++){
      ai[i] = sc.nextInt();
    }
    
    Arrays.sort(ai);


    for(int i = 1; i<=N; i++){
      if(i % 2 != 0){
        Alice_score += ai[N-i];
      } else {
        Bob_score += ai[N-i];
      }
    }

    System.out.println(Alice_score - Bob_score);
  } int Alice_score =0; Alice_score 0 int Bob_score =0; Bob_score 0 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int ai[] = new int[N]; ai new int[N] N for(int i = 0; i<N; i++){
      ai[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
      ai[i] = sc.nextInt();
    } {
      ai[i] = sc.nextInt();
    } ai[i] = sc.nextInt() ai[i] ai i sc.nextInt() sc.nextInt sc Arrays.sort(ai) Arrays.sort Arrays ai for(int i = 1; i<=N; i++){
      if(i % 2 != 0){
        Alice_score += ai[N-i];
      } else {
        Bob_score += ai[N-i];
      }
    } int i = 1; int i = 1; i 1 i<=N i N i++ i++ i {
      if(i % 2 != 0){
        Alice_score += ai[N-i];
      } else {
        Bob_score += ai[N-i];
      }
    } {
      if(i % 2 != 0){
        Alice_score += ai[N-i];
      } else {
        Bob_score += ai[N-i];
      }
    } if(i % 2 != 0){
        Alice_score += ai[N-i];
      } else {
        Bob_score += ai[N-i];
      } i % 2 != 0 i % 2 i 2 0 {
        Alice_score += ai[N-i];
      } Alice_score += ai[N-i] Alice_score ai[N-i] ai N-i N i {
        Bob_score += ai[N-i];
      } Bob_score += ai[N-i] Bob_score ai[N-i] ai N-i N i System.out.println(Alice_score - Bob_score) System.out.println System.out System System.out Alice_score - Bob_score Alice_score Bob_score String[]args args public class Main {
  public static void main (String[]args) {
    int Alice_score =0;
    int Bob_score =0;
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ai[] = new int[N];
    
    for(int i = 0; i<N; i++){
      ai[i] = sc.nextInt();
    }
    
    Arrays.sort(ai);


    for(int i = 1; i<=N; i++){
      if(i % 2 != 0){
        Alice_score += ai[N-i];
      } else {
        Bob_score += ai[N-i];
      }
    }

    System.out.println(Alice_score - Bob_score);
  }
} public class Main {
  public static void main (String[]args) {
    int Alice_score =0;
    int Bob_score =0;
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ai[] = new int[N];
    
    for(int i = 0; i<N; i++){
      ai[i] = sc.nextInt();
    }
    
    Arrays.sort(ai);


    for(int i = 1; i<=N; i++){
      if(i % 2 != 0){
        Alice_score += ai[N-i];
      } else {
        Bob_score += ai[N-i];
      }
    }

    System.out.println(Alice_score - Bob_score);
  }
} Main
import java.util.Scanner;
import java.util.Arrays;
public class Main {
  public static void main (String[]args) {
    int Alice_score =0;
    int Bob_score =0;
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ai[] = new int[N];
    
    for(int i = 0; i<N; i++){
      ai[i] = sc.nextInt();
    }
    
    Arrays.sort(ai);


    for(int i = 1; i<=N; i++){
      if(i % 2 != 0){
        Alice_score += ai[N-i];
      } else {
        Bob_score += ai[N-i];
      }
    }

    System.out.println(Alice_score - Bob_score);
  }
}
