#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k = 0, i, j, s = 0, t, z = 1;
  cin >> n;
  long long int a[n], b[n];
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++)
    for (j = i + 1; j < n; j++)
      if (a[i] > a[j]) {
        t = a[i];
        a[i] = a[j];
        a[j] = t;
      }
  for (i = 0; i < n; i += 2) s += a[i + 1] - a[i];
  cout << s;
}
