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