#include <bits/stdc++.h>
int main() {
  int i, j, k = 0, n, t;
  scanf("%d", &n);
  int arr[n];
  for (i = 0; i < n; i++) scanf("%d", &arr[i]);
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (arr[i] > arr[j]) {
        t = arr[i];
        arr[i] = arr[j];
        arr[j] = t;
      }
    }
  }
  for (i = 0; i < n - 1; i = i + 2) k = k + arr[i + 1] - arr[i];
  printf("%d\n", k);
  return 0;
}
