import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    int alice = 0;
    Arrays.sort(a);
    reverse(a);
    for(int i = 0; i < n; i++){
      alice += (i % 2 == 0) ? a[i] : -a[i];
    }
    System.out.println(alice);
  }
  
  public static int[] reverse(int[] array){
    for(int i = 0; i < array.length/2; i++){
      int tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    }
    return array;
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    int alice = 0;
    Arrays.sort(a);
    reverse(a);
    for(int i = 0; i < n; i++){
      alice += (i % 2 == 0) ? a[i] : -a[i];
    }
    System.out.println(alice);
  }
  
  public static int[] reverse(int[] array){
    for(int i = 0; i < array.length/2; i++){
      int tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    }
    return array;
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    int alice = 0;
    Arrays.sort(a);
    reverse(a);
    for(int i = 0; i < n; i++){
      alice += (i % 2 == 0) ? a[i] : -a[i];
    }
    System.out.println(alice);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    int alice = 0;
    Arrays.sort(a);
    reverse(a);
    for(int i = 0; i < n; i++){
      alice += (i % 2 == 0) ? a[i] : -a[i];
    }
    System.out.println(alice);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] a = new int[n]; a new int[n] n for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      a[i] = sc.nextInt();
    } {
      a[i] = sc.nextInt();
    } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc int alice = 0; alice 0 Arrays.sort(a) Arrays.sort Arrays a reverse(a) reverse a for(int i = 0; i < n; i++){
      alice += (i % 2 == 0) ? a[i] : -a[i];
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      alice += (i % 2 == 0) ? a[i] : -a[i];
    } {
      alice += (i % 2 == 0) ? a[i] : -a[i];
    } alice += (i % 2 == 0) ? a[i] : -a[i] alice (i % 2 == 0) ? a[i] : -a[i] (i % 2 == 0) i % 2 i 2 0 a[i] a i -a[i] a[i] a i System.out.println(alice) System.out.println System.out System System.out alice String[] args args public static int[] reverse(int[] array){
    for(int i = 0; i < array.length/2; i++){
      int tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    }
    return array;
  } reverse {
    for(int i = 0; i < array.length/2; i++){
      int tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    }
    return array;
  } for(int i = 0; i < array.length/2; i++){
      int tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    } int i = 0; int i = 0; i 0 i < array.length/2 i array.length/2 array.length array array.length 2 i++ i++ i {
      int tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    } {
      int tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    } int tmp = array[i]; tmp array[i] array i array[i] = array[array.length - 1 - i] array[i] array i array[array.length - 1 - i] array array.length - 1 - i array.length - 1 - i array.length array array.length 1 i array[array.length - 1 - i] = tmp array[array.length - 1 - i] array array.length - 1 - i array.length - 1 - i array.length array array.length 1 i tmp return array; array int[] array array public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    int alice = 0;
    Arrays.sort(a);
    reverse(a);
    for(int i = 0; i < n; i++){
      alice += (i % 2 == 0) ? a[i] : -a[i];
    }
    System.out.println(alice);
  }
  
  public static int[] reverse(int[] array){
    for(int i = 0; i < array.length/2; i++){
      int tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    }
    return array;
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    int alice = 0;
    Arrays.sort(a);
    reverse(a);
    for(int i = 0; i < n; i++){
      alice += (i % 2 == 0) ? a[i] : -a[i];
    }
    System.out.println(alice);
  }
  
  public static int[] reverse(int[] array){
    for(int i = 0; i < array.length/2; i++){
      int tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    }
    return array;
  }
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    int alice = 0;
    Arrays.sort(a);
    reverse(a);
    for(int i = 0; i < n; i++){
      alice += (i % 2 == 0) ? a[i] : -a[i];
    }
    System.out.println(alice);
  }
  
  public static int[] reverse(int[] array){
    for(int i = 0; i < array.length/2; i++){
      int tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    }
    return array;
  }
}