#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<int> v(n);
    int vis[101] = {0};
    for (int i = 0; i < n; i++) cin >> v[i];
    int index;
    sort(v.begin(), v.end());
    int res = 0;
    for (int i = 0; i < n; i += 2) {
      res += abs(v[i] - v[i + 1]);
    }
    cout << res << "\n";
  }
}
