import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] xs = new int[n];
    for (int i = 0; i < xs.length; i++) {
      xs[i] = sc.nextInt();
    }
    Arrays.sort(xs);
    int a = 0;
    int b = 0;
    int index = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (index % 2 == 0)
        a += xs[i];
      else
        b += xs[i];
      index++;
    }

    System.out.println(a - b);
    sc.close();
  }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] xs = new int[n];
    for (int i = 0; i < xs.length; i++) {
      xs[i] = sc.nextInt();
    }
    Arrays.sort(xs);
    int a = 0;
    int b = 0;
    int index = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (index % 2 == 0)
        a += xs[i];
      else
        b += xs[i];
      index++;
    }

    System.out.println(a - b);
    sc.close();
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] xs = new int[n];
    for (int i = 0; i < xs.length; i++) {
      xs[i] = sc.nextInt();
    }
    Arrays.sort(xs);
    int a = 0;
    int b = 0;
    int index = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (index % 2 == 0)
        a += xs[i];
      else
        b += xs[i];
      index++;
    }

    System.out.println(a - b);
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] xs = new int[n];
    for (int i = 0; i < xs.length; i++) {
      xs[i] = sc.nextInt();
    }
    Arrays.sort(xs);
    int a = 0;
    int b = 0;
    int index = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (index % 2 == 0)
        a += xs[i];
      else
        b += xs[i];
      index++;
    }

    System.out.println(a - b);
    sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] xs = new int[n]; xs new int[n] n for (int i = 0; i < xs.length; i++) {
      xs[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i < xs.length i xs.length xs xs.length i++ i++ i {
      xs[i] = sc.nextInt();
    } {
      xs[i] = sc.nextInt();
    } xs[i] = sc.nextInt() xs[i] xs i sc.nextInt() sc.nextInt sc Arrays.sort(xs) Arrays.sort Arrays xs int a = 0; a 0 int b = 0; b 0 int index = 0; index 0 for (int i = n - 1; i >= 0; i--) {
      if (index % 2 == 0)
        a += xs[i];
      else
        b += xs[i];
      index++;
    } int i = n - 1; int i = n - 1; i n - 1 n 1 i >= 0 i 0 i-- i-- i {
      if (index % 2 == 0)
        a += xs[i];
      else
        b += xs[i];
      index++;
    } {
      if (index % 2 == 0)
        a += xs[i];
      else
        b += xs[i];
      index++;
    } if (index % 2 == 0)
        a += xs[i];
      else
        b += xs[i]; index % 2 == 0 index % 2 index 2 0 a += xs[i] a xs[i] xs i b += xs[i] b xs[i] xs i index++ index System.out.println(a - b) System.out.println System.out System System.out a - b a b sc.close() sc.close sc String[] args args
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] xs = new int[n];
    for (int i = 0; i < xs.length; i++) {
      xs[i] = sc.nextInt();
    }
    Arrays.sort(xs);
    int a = 0;
    int b = 0;
    int index = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (index % 2 == 0)
        a += xs[i];
      else
        b += xs[i];
      index++;
    }

    System.out.println(a - b);
    sc.close();
  }
}
