#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  int ct = 0;
  cin >> n;
  int b[n];
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  sort(b, b + n);
  for (int i = 0; i < n - 1; i += 2) {
    int j = i + 1;
    ct = ct + b[j] - b[i];
  }
  cout << ct;
}
