#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  priority_queue<int> pq;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    pq.push(a);
  }
  int ans = 0;
  while (!pq.empty()) {
    int f = pq.top();
    pq.pop();
    int s = pq.top();
    pq.pop();
    ans += f - s;
  }
  printf("%d", ans);
  return 0;
}
