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