#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 1000005;
int SetBit(int n, int x) { return n | (1 << x); }
int ClearBit(int n, int x) { return n & ~(1 << x); }
int ToggleBit(int n, int x) { return n ^ (1 << x); }
bool CheckBit(int n, int x) { return (bool)(n & (1 << x)); }
int arr[105];
int main(void) {
  int n, i, ans;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) scanf("%d", &arr[i]);
    sort(arr, arr + n);
    ans = 0;
    for (i = 1; i < n; i += 2) ans += arr[i] - arr[i - 1];
    printf("%d\n", ans);
  }
  return 0;
}
