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