#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0;
  cin >> n;
  vector<int> arr(n);
  for (auto &x : arr) cin >> x;
  sort(arr.begin(), arr.end());
  for (int i = 0; i < n; i += 2) {
    sum += arr[i + 1] - arr[i];
  }
  cout << sum;
}
