import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    List<Integer> as = new ArrayList<>();
    
    for(int i = 0; i < N; i++) {
        as.add(sc.nextInt());
    }

    Collections.sort(as, Collections.reverseOrder());
    
    int res = 0;
    for(int i = 0; i < as.size(); i++) {
        
        if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        }
    }
    
    System.out.println(res);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    List<Integer> as = new ArrayList<>();
    
    for(int i = 0; i < N; i++) {
        as.add(sc.nextInt());
    }

    Collections.sort(as, Collections.reverseOrder());
    
    int res = 0;
    for(int i = 0; i < as.size(); i++) {
        
        if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        }
    }
    
    System.out.println(res);
  }
} Main public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    List<Integer> as = new ArrayList<>();
    
    for(int i = 0; i < N; i++) {
        as.add(sc.nextInt());
    }

    Collections.sort(as, Collections.reverseOrder());
    
    int res = 0;
    for(int i = 0; i < as.size(); i++) {
        
        if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        }
    }
    
    System.out.println(res);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    List<Integer> as = new ArrayList<>();
    
    for(int i = 0; i < N; i++) {
        as.add(sc.nextInt());
    }

    Collections.sort(as, Collections.reverseOrder());
    
    int res = 0;
    for(int i = 0; i < as.size(); i++) {
        
        if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        }
    }
    
    System.out.println(res);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc List<Integer> as = new ArrayList<>(); as new ArrayList<>() for(int i = 0; i < N; i++) {
        as.add(sc.nextInt());
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
        as.add(sc.nextInt());
    } {
        as.add(sc.nextInt());
    } as.add(sc.nextInt()) as.add as sc.nextInt() sc.nextInt sc Collections.sort(as, Collections.reverseOrder()) Collections.sort Collections as Collections.reverseOrder() Collections.reverseOrder Collections int res = 0; res 0 for(int i = 0; i < as.size(); i++) {
        
        if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        }
    } int i = 0; int i = 0; i 0 i < as.size() i as.size() as.size as i++ i++ i {
        
        if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        }
    } {
        
        if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        }
    } if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        } i == 0 || i % 2 == 0 i == 0 i 0 i % 2 == 0 i % 2 i 2 0 {
            res += as.get(i);
        } res += as.get(i) res as.get(i) as.get as i {
            res -= as.get(i);
        } res -= as.get(i) res as.get(i) as.get as i System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    List<Integer> as = new ArrayList<>();
    
    for(int i = 0; i < N; i++) {
        as.add(sc.nextInt());
    }

    Collections.sort(as, Collections.reverseOrder());
    
    int res = 0;
    for(int i = 0; i < as.size(); i++) {
        
        if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        }
    }
    
    System.out.println(res);
  }
} public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    List<Integer> as = new ArrayList<>();
    
    for(int i = 0; i < N; i++) {
        as.add(sc.nextInt());
    }

    Collections.sort(as, Collections.reverseOrder());
    
    int res = 0;
    for(int i = 0; i < as.size(); i++) {
        
        if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        }
    }
    
    System.out.println(res);
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    List<Integer> as = new ArrayList<>();
    
    for(int i = 0; i < N; i++) {
        as.add(sc.nextInt());
    }

    Collections.sort(as, Collections.reverseOrder());
    
    int res = 0;
    for(int i = 0; i < as.size(); i++) {
        
        if(i == 0 || i % 2 == 0){
            res += as.get(i);
        } else {
            res -= as.get(i);
        }
    }
    
    System.out.println(res);
  }
}
