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