#include <bits/stdc++.h>
using namespace std;
const int inf = 1e2 + 9;
int a[inf];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int ans = 0;
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i += 2) {
    ans += a[i + 1] - a[i];
  }
  cout << ans << endl;
}
