#include <bits/stdc++.h>
using namespace std;
int a[110], b[110];
int main() {
  int n, s = 0, t;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (int i = 1; i < n; i += 2) {
    s += abs(a[i + 1] - a[i]);
  }
  printf("%d", s);
}
