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