#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, i, b, cnt = 0;
  vector<int> v;
  cin >> a;
  while (a--) {
    cin >> b;
    v.push_back(b);
  }
  sort(v.begin(), v.end());
  for (i = 1; i < v.size(); i += 2) {
    cnt += v[i] - v[i - 1];
  }
  cout << cnt << endl;
  return 0;
}
