#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, ans = 0, i, temp;
  vector<int> a;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> temp;
    a.push_back(temp);
  }
  sort(a.begin(), a.end());
  for (i = 0; i < n; i = i + 2) {
    if (a[i] != a[i + 1]) {
      ans += (a[i + 1] - a[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
