import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int[] card = new int[num];
    int alice = 0;
    int bob = 0;
    for(int i = 0; i < num; i++){
      card[i] = sc.nextInt();
    }
    Arrays.sort(card);
    for (int i = (num-1); i>=0; i-=2){
      alice += card[i];
    }
    for (int j = (num-2); j>=0; j-=2){
     bob += card[j];	
    }
    int division = alice - bob;
    System.out.println(division);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int[] card = new int[num];
    int alice = 0;
    int bob = 0;
    for(int i = 0; i < num; i++){
      card[i] = sc.nextInt();
    }
    Arrays.sort(card);
    for (int i = (num-1); i>=0; i-=2){
      alice += card[i];
    }
    for (int j = (num-2); j>=0; j-=2){
     bob += card[j];	
    }
    int division = alice - bob;
    System.out.println(division);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int[] card = new int[num];
    int alice = 0;
    int bob = 0;
    for(int i = 0; i < num; i++){
      card[i] = sc.nextInt();
    }
    Arrays.sort(card);
    for (int i = (num-1); i>=0; i-=2){
      alice += card[i];
    }
    for (int j = (num-2); j>=0; j-=2){
     bob += card[j];	
    }
    int division = alice - bob;
    System.out.println(division);
  } main {
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int[] card = new int[num];
    int alice = 0;
    int bob = 0;
    for(int i = 0; i < num; i++){
      card[i] = sc.nextInt();
    }
    Arrays.sort(card);
    for (int i = (num-1); i>=0; i-=2){
      alice += card[i];
    }
    for (int j = (num-2); j>=0; j-=2){
     bob += card[j];	
    }
    int division = alice - bob;
    System.out.println(division);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc int[] card = new int[num]; card new int[num] num int alice = 0; alice 0 int bob = 0; bob 0 for(int i = 0; i < num; i++){
      card[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
      card[i] = sc.nextInt();
    } {
      card[i] = sc.nextInt();
    } card[i] = sc.nextInt() card[i] card i sc.nextInt() sc.nextInt sc Arrays.sort(card) Arrays.sort Arrays card for (int i = (num-1); i>=0; i-=2){
      alice += card[i];
    } int i = (num-1); int i = (num-1); i (num-1) num 1 i>=0 i 0 i-=2 i-=2 i 2 {
      alice += card[i];
    } {
      alice += card[i];
    } alice += card[i] alice card[i] card i for (int j = (num-2); j>=0; j-=2){
     bob += card[j];	
    } int j = (num-2); int j = (num-2); j (num-2) num 2 j>=0 j 0 j-=2 j-=2 j 2 {
     bob += card[j];	
    } {
     bob += card[j];	
    } bob += card[j] bob card[j] card j int division = alice - bob; division alice - bob alice bob System.out.println(division) System.out.println System.out System System.out division String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int[] card = new int[num];
    int alice = 0;
    int bob = 0;
    for(int i = 0; i < num; i++){
      card[i] = sc.nextInt();
    }
    Arrays.sort(card);
    for (int i = (num-1); i>=0; i-=2){
      alice += card[i];
    }
    for (int j = (num-2); j>=0; j-=2){
     bob += card[j];	
    }
    int division = alice - bob;
    System.out.println(division);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int[] card = new int[num];
    int alice = 0;
    int bob = 0;
    for(int i = 0; i < num; i++){
      card[i] = sc.nextInt();
    }
    Arrays.sort(card);
    for (int i = (num-1); i>=0; i-=2){
      alice += card[i];
    }
    for (int j = (num-2); j>=0; j-=2){
     bob += card[j];	
    }
    int division = alice - bob;
    System.out.println(division);
  }
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int[] card = new int[num];
    int alice = 0;
    int bob = 0;
    for(int i = 0; i < num; i++){
      card[i] = sc.nextInt();
    }
    Arrays.sort(card);
    for (int i = (num-1); i>=0; i-=2){
      alice += card[i];
    }
    for (int j = (num-2); j>=0; j-=2){
     bob += card[j];	
    }
    int division = alice - bob;
    System.out.println(division);
  }
}
