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