#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, s;
  cin >> n;
  vector<long long> vc;
  for (long long i = 0; i < n; i++) {
    cin >> s;
    vc.push_back(s);
  }
  sort(vc.begin(), vc.end());
  long long ans = 0;
  for (long long i = 0; i < n - 1; i += 2) ans += vc[i + 1] - vc[i];
  cout << ans << "\n";
  return 0;
}
