#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 55;
const int inf = 1e9 + 77;
const int MOD = 1e9 + 7;
const double PI = 3.14159265359;
const double eps = 1e-7;
int arr[110];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  sort(arr, arr + n);
  for (int i = 1; i < n; i += 2) {
    sum += arr[i] - arr[i - 1];
  }
  cout << sum << "\n";
  return 0;
}
