#include <bits/stdc++.h>
using namespace std;
int arr[110];
vector<pair<long long, long long> > v;
vector<long long> c;
int main(void) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  int res = 0;
  for (int i = 0; i < n; i += 2) {
    res += arr[i + 1] - arr[i];
  }
  cout << res << endl;
}
