#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, in, diff = 0;
  cin >> n;
  vector<int> team;
  for (int i = 0; i < n; i++) {
    cin >> in;
    team.push_back(in);
  }
  sort(team.begin(), team.end());
  for (int i = 0; i < n - 1; i++) {
    diff = diff + abs(team[i] - team[i + 1]);
    i++;
  }
  cout << diff;
}
