import java.util.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cardNum = sc.nextInt();
    
    List<Integer> numList = new ArrayList<>();
    
    while(sc.hasNextInt()){
      numList.add(sc.nextInt());
    }
    
    Collections.sort(numList, Collections.reverseOrder());
    
    int aliceSum = 0;
    int bobSum = 0;
    
    for(int i = 0; i < cardNum; i++){
      if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      }
      
    }
    
    System.out.println(aliceSum - bobSum);
  }

} import java.util.*; util.* java public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cardNum = sc.nextInt();
    
    List<Integer> numList = new ArrayList<>();
    
    while(sc.hasNextInt()){
      numList.add(sc.nextInt());
    }
    
    Collections.sort(numList, Collections.reverseOrder());
    
    int aliceSum = 0;
    int bobSum = 0;
    
    for(int i = 0; i < cardNum; i++){
      if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      }
      
    }
    
    System.out.println(aliceSum - bobSum);
  }

} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cardNum = sc.nextInt();
    
    List<Integer> numList = new ArrayList<>();
    
    while(sc.hasNextInt()){
      numList.add(sc.nextInt());
    }
    
    Collections.sort(numList, Collections.reverseOrder());
    
    int aliceSum = 0;
    int bobSum = 0;
    
    for(int i = 0; i < cardNum; i++){
      if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      }
      
    }
    
    System.out.println(aliceSum - bobSum);
  } main {
    Scanner sc = new Scanner(System.in);
    int cardNum = sc.nextInt();
    
    List<Integer> numList = new ArrayList<>();
    
    while(sc.hasNextInt()){
      numList.add(sc.nextInt());
    }
    
    Collections.sort(numList, Collections.reverseOrder());
    
    int aliceSum = 0;
    int bobSum = 0;
    
    for(int i = 0; i < cardNum; i++){
      if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      }
      
    }
    
    System.out.println(aliceSum - bobSum);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int cardNum = sc.nextInt(); cardNum sc.nextInt() sc.nextInt sc List<Integer> numList = new ArrayList<>(); numList new ArrayList<>() while(sc.hasNextInt()){
      numList.add(sc.nextInt());
    } sc.hasNextInt() sc.hasNextInt sc {
      numList.add(sc.nextInt());
    } numList.add(sc.nextInt()) numList.add numList sc.nextInt() sc.nextInt sc Collections.sort(numList, Collections.reverseOrder()) Collections.sort Collections numList Collections.reverseOrder() Collections.reverseOrder Collections int aliceSum = 0; aliceSum 0 int bobSum = 0; bobSum 0 for(int i = 0; i < cardNum; i++){
      if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      }
      
    } int i = 0; int i = 0; i 0 i < cardNum i cardNum i++ i++ i {
      if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      }
      
    } {
      if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      }
      
    } if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      } i % 2 == 0 i % 2 i 2 0 {
        aliceSum += numList.get(i);
      } aliceSum += numList.get(i) aliceSum numList.get(i) numList.get numList i {
        bobSum += numList.get(i);
      } bobSum += numList.get(i) bobSum numList.get(i) numList.get numList i System.out.println(aliceSum - bobSum) System.out.println System.out System System.out aliceSum - bobSum aliceSum bobSum String[] args args public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cardNum = sc.nextInt();
    
    List<Integer> numList = new ArrayList<>();
    
    while(sc.hasNextInt()){
      numList.add(sc.nextInt());
    }
    
    Collections.sort(numList, Collections.reverseOrder());
    
    int aliceSum = 0;
    int bobSum = 0;
    
    for(int i = 0; i < cardNum; i++){
      if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      }
      
    }
    
    System.out.println(aliceSum - bobSum);
  }

} public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cardNum = sc.nextInt();
    
    List<Integer> numList = new ArrayList<>();
    
    while(sc.hasNextInt()){
      numList.add(sc.nextInt());
    }
    
    Collections.sort(numList, Collections.reverseOrder());
    
    int aliceSum = 0;
    int bobSum = 0;
    
    for(int i = 0; i < cardNum; i++){
      if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      }
      
    }
    
    System.out.println(aliceSum - bobSum);
  }

} Main
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cardNum = sc.nextInt();
    
    List<Integer> numList = new ArrayList<>();
    
    while(sc.hasNextInt()){
      numList.add(sc.nextInt());
    }
    
    Collections.sort(numList, Collections.reverseOrder());
    
    int aliceSum = 0;
    int bobSum = 0;
    
    for(int i = 0; i < cardNum; i++){
      if(i % 2 == 0){
        aliceSum += numList.get(i);
      }else {
        bobSum += numList.get(i);
      }
      
    }
    
    System.out.println(aliceSum - bobSum);
  }

}