#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, total = 0;
  cin >> n;
  int arr[n + 1];
  for (int i = 1; i <= n; i++) cin >> arr[i];
  sort(arr + 1, arr + n + 1);
  for (int p = 2; p <= n; p += 2) {
    total += (arr[p] - arr[p - 1]);
  }
  cout << total << endl;
  return 0;
}
