import java.util.*;
import java.util.TreeMap;

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

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