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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int ans = 0;
    int sumAlice = 0;
    int sumBob = 0;

    for (int cnt = 0; cnt < n; cnt++) {
      a[cnt] = sc.nextInt();
    }
    Arrays.sort(a);

    for (int cnt = 0; cnt < n; cnt++) {
      int tmp = a[n - cnt -1];
      if (cnt % 2 == 0) {
        sumAlice += tmp;
      }
      else{
        sumBob += tmp;
      }
    }
    ans = sumAlice - sumBob;
    System.out.println(ans);
    sc.close();
  }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays 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];
    int ans = 0;
    int sumAlice = 0;
    int sumBob = 0;

    for (int cnt = 0; cnt < n; cnt++) {
      a[cnt] = sc.nextInt();
    }
    Arrays.sort(a);

    for (int cnt = 0; cnt < n; cnt++) {
      int tmp = a[n - cnt -1];
      if (cnt % 2 == 0) {
        sumAlice += tmp;
      }
      else{
        sumBob += tmp;
      }
    }
    ans = sumAlice - sumBob;
    System.out.println(ans);
    sc.close();
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int ans = 0;
    int sumAlice = 0;
    int sumBob = 0;

    for (int cnt = 0; cnt < n; cnt++) {
      a[cnt] = sc.nextInt();
    }
    Arrays.sort(a);

    for (int cnt = 0; cnt < n; cnt++) {
      int tmp = a[n - cnt -1];
      if (cnt % 2 == 0) {
        sumAlice += tmp;
      }
      else{
        sumBob += tmp;
      }
    }
    ans = sumAlice - sumBob;
    System.out.println(ans);
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int ans = 0;
    int sumAlice = 0;
    int sumBob = 0;

    for (int cnt = 0; cnt < n; cnt++) {
      a[cnt] = sc.nextInt();
    }
    Arrays.sort(a);

    for (int cnt = 0; cnt < n; cnt++) {
      int tmp = a[n - cnt -1];
      if (cnt % 2 == 0) {
        sumAlice += tmp;
      }
      else{
        sumBob += tmp;
      }
    }
    ans = sumAlice - sumBob;
    System.out.println(ans);
    sc.close();
  } 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 int ans = 0; ans 0 int sumAlice = 0; sumAlice 0 int sumBob = 0; sumBob 0 for (int cnt = 0; cnt < n; cnt++) {
      a[cnt] = sc.nextInt();
    } int cnt = 0; int cnt = 0; cnt 0 cnt < n cnt n cnt++ cnt++ cnt {
      a[cnt] = sc.nextInt();
    } {
      a[cnt] = sc.nextInt();
    } a[cnt] = sc.nextInt() a[cnt] a cnt sc.nextInt() sc.nextInt sc Arrays.sort(a) Arrays.sort Arrays a for (int cnt = 0; cnt < n; cnt++) {
      int tmp = a[n - cnt -1];
      if (cnt % 2 == 0) {
        sumAlice += tmp;
      }
      else{
        sumBob += tmp;
      }
    } int cnt = 0; int cnt = 0; cnt 0 cnt < n cnt n cnt++ cnt++ cnt {
      int tmp = a[n - cnt -1];
      if (cnt % 2 == 0) {
        sumAlice += tmp;
      }
      else{
        sumBob += tmp;
      }
    } {
      int tmp = a[n - cnt -1];
      if (cnt % 2 == 0) {
        sumAlice += tmp;
      }
      else{
        sumBob += tmp;
      }
    } int tmp = a[n - cnt -1]; tmp a[n - cnt -1] a n - cnt -1 n - cnt -1 n cnt 1 if (cnt % 2 == 0) {
        sumAlice += tmp;
      }
      else{
        sumBob += tmp;
      } cnt % 2 == 0 cnt % 2 cnt 2 0 {
        sumAlice += tmp;
      } sumAlice += tmp sumAlice tmp {
        sumBob += tmp;
      } sumBob += tmp sumBob tmp ans = sumAlice - sumBob ans sumAlice - sumBob sumAlice sumBob System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int ans = 0;
    int sumAlice = 0;
    int sumBob = 0;

    for (int cnt = 0; cnt < n; cnt++) {
      a[cnt] = sc.nextInt();
    }
    Arrays.sort(a);

    for (int cnt = 0; cnt < n; cnt++) {
      int tmp = a[n - cnt -1];
      if (cnt % 2 == 0) {
        sumAlice += tmp;
      }
      else{
        sumBob += tmp;
      }
    }
    ans = sumAlice - sumBob;
    System.out.println(ans);
    sc.close();
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int ans = 0;
    int sumAlice = 0;
    int sumBob = 0;

    for (int cnt = 0; cnt < n; cnt++) {
      a[cnt] = sc.nextInt();
    }
    Arrays.sort(a);

    for (int cnt = 0; cnt < n; cnt++) {
      int tmp = a[n - cnt -1];
      if (cnt % 2 == 0) {
        sumAlice += tmp;
      }
      else{
        sumBob += tmp;
      }
    }
    ans = sumAlice - sumBob;
    System.out.println(ans);
    sc.close();
  }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int ans = 0;
    int sumAlice = 0;
    int sumBob = 0;

    for (int cnt = 0; cnt < n; cnt++) {
      a[cnt] = sc.nextInt();
    }
    Arrays.sort(a);

    for (int cnt = 0; cnt < n; cnt++) {
      int tmp = a[n - cnt -1];
      if (cnt % 2 == 0) {
        sumAlice += tmp;
      }
      else{
        sumBob += tmp;
      }
    }
    ans = sumAlice - sumBob;
    System.out.println(ans);
    sc.close();
  }
}