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