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