import java.util.*;
class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
      ArrayList<Integer> arr = new ArrayList<>();
      for(int i = 0;i<n ; i++){
          arr.add(scan.nextInt());
      }
      
      Collections.sort(arr,Collections.reverseOrder()) ;
      //System.out.println(arr);
      
      int sum = 0 , sum2 = 0 ;
      for(int i = 0;i<n ; i++){
          if(i%2==0){
             sum+=arr.get(i) ;
              
          }else{
              sum2+=arr.get(i);
          }
      }
      
      System.out.println(Math.abs(sum-sum2));
    }
} import java.util.*; util.* java class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
      ArrayList<Integer> arr = new ArrayList<>();
      for(int i = 0;i<n ; i++){
          arr.add(scan.nextInt());
      }
      
      Collections.sort(arr,Collections.reverseOrder()) ;
      //System.out.println(arr);
      
      int sum = 0 , sum2 = 0 ;
      for(int i = 0;i<n ; i++){
          if(i%2==0){
             sum+=arr.get(i) ;
              
          }else{
              sum2+=arr.get(i);
          }
      }
      
      System.out.println(Math.abs(sum-sum2));
    }
} Main public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
      ArrayList<Integer> arr = new ArrayList<>();
      for(int i = 0;i<n ; i++){
          arr.add(scan.nextInt());
      }
      
      Collections.sort(arr,Collections.reverseOrder()) ;
      //System.out.println(arr);
      
      int sum = 0 , sum2 = 0 ;
      for(int i = 0;i<n ; i++){
          if(i%2==0){
             sum+=arr.get(i) ;
              
          }else{
              sum2+=arr.get(i);
          }
      }
      
      System.out.println(Math.abs(sum-sum2));
    } main {
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
      ArrayList<Integer> arr = new ArrayList<>();
      for(int i = 0;i<n ; i++){
          arr.add(scan.nextInt());
      }
      
      Collections.sort(arr,Collections.reverseOrder()) ;
      //System.out.println(arr);
      
      int sum = 0 , sum2 = 0 ;
      for(int i = 0;i<n ; i++){
          if(i%2==0){
             sum+=arr.get(i) ;
              
          }else{
              sum2+=arr.get(i);
          }
      }
      
      System.out.println(Math.abs(sum-sum2));
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt() ; n scan.nextInt() scan.nextInt scan ArrayList<Integer> arr = new ArrayList<>(); arr new ArrayList<>() for(int i = 0;i<n ; i++){
          arr.add(scan.nextInt());
      } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
          arr.add(scan.nextInt());
      } {
          arr.add(scan.nextInt());
      } arr.add(scan.nextInt()) arr.add arr scan.nextInt() scan.nextInt scan Collections.sort(arr,Collections.reverseOrder()) Collections.sort Collections arr Collections.reverseOrder() Collections.reverseOrder Collections int sum = 0 sum 0 sum2 = 0 ; sum2 0 for(int i = 0;i<n ; i++){
          if(i%2==0){
             sum+=arr.get(i) ;
              
          }else{
              sum2+=arr.get(i);
          }
      } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
          if(i%2==0){
             sum+=arr.get(i) ;
              
          }else{
              sum2+=arr.get(i);
          }
      } {
          if(i%2==0){
             sum+=arr.get(i) ;
              
          }else{
              sum2+=arr.get(i);
          }
      } if(i%2==0){
             sum+=arr.get(i) ;
              
          }else{
              sum2+=arr.get(i);
          } i%2==0 i%2 i 2 0 {
             sum+=arr.get(i) ;
              
          } sum+=arr.get(i) sum arr.get(i) arr.get arr i {
              sum2+=arr.get(i);
          } sum2+=arr.get(i) sum2 arr.get(i) arr.get arr i System.out.println(Math.abs(sum-sum2)) System.out.println System.out System System.out Math.abs(sum-sum2) Math.abs Math sum-sum2 sum sum2 String []args args
import java.util.*;
class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
      ArrayList<Integer> arr = new ArrayList<>();
      for(int i = 0;i<n ; i++){
          arr.add(scan.nextInt());
      }
      
      Collections.sort(arr,Collections.reverseOrder()) ;
      //System.out.println(arr);
      
      int sum = 0 , sum2 = 0 ;
      for(int i = 0;i<n ; i++){
          if(i%2==0){
             sum+=arr.get(i) ;
              
          }else{
              sum2+=arr.get(i);
          }
      }
      
      System.out.println(Math.abs(sum-sum2));
    }
}