/// Containers Start
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <cstdlib>
#include <iterator>
#include <algorithm>
/// C Header Files
#include <cstdio>
#include <cctype>
#include <cmath>
#include <math.h>
#include <ctime>
#include <cstring>
/// Containers End


using namespace std;


/// Math Start
#define PI                    acos(-1.0)
#define Pi                    3.141592653589793
#define EPS (1e-7)
#define INF (1e9)
/// Math End


/// Extra Start
#define nn                    '\n'
#define pb                    push_back
#define SS                    stringstream
#define ull                   unsigned long long
#define mod                   1000000007
#define SIZE                  2000001
#define _cin                  ios_base::sync_with_stdio(0);  cin.tie(0);
#define sz(a)                 int((a).size())
#define space                 " "
#define all(x)                (x).begin(), (x).end()
#define Ignore                cin.ignore()
#define StringToInt           if ( ! (istringstream(s) >> n) ) n = 0;
/// Extra End


/// Functions Start
template<class T>
T Multiply(T a, T b) { return a * b; }

template<class T>
T larger(T a, T b) { return (a > b ? a : b); }

template<class T>
T smaller(T a, T b) { return (a < b ? a : b); }

template<class T>
T gcd(T a, T b) {
    if (b == 0)return a;
    return gcd(b, a % b);
}

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<class T>
string converter(T n) {
    SS x;
    x << n;
    return x.str();
}

#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define FORD(i, a, b) for(int i=(a);i>=(b);i--)
#define FORA(arr) for(auto &i:arr)
#define Cin(a)            cin>>a;
#define Cin2(a, b)        cin>>a>>b;
#define Cin3(a, b, c)        cin>>a>>b>>c;
#define Cin4(a, b, c, d)   cin>>a>>b>>c>>d;
/// Functions End


/// Array Start
#define SET(a)                memset( a, -1,    sizeof a )
#define CLR(a)                memset( a,  0,    sizeof a )
#define MEM(a, val)            memset( a,  val,  sizeof(a) )
/// Array End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define deb3(x, y, z) cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z << end
/// Debug End


/// TypeDef Start
typedef long long int ll;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef map<char, int> mci;
typedef map<int, string> mis;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<pii> vii;
/// TypeDef End

/****************** Geometry *****************/

template<typename T>
inline T PointDistanceHorVer(T x1, T y1, T x2, T y2) { return abs(x1 - x2) + abs(y1 - y2); }

template<typename T>
inline T PointDistanceDiagonally(T x1, T y1, T x2, T y2) { return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); }

template<typename T>
inline T PointDistanceMinimum(T x1, T y1, T x2, T y2) {
    T tmp1 = abs(x1 - x2);
    T tmp2 = abs(y1 - y2);
    T tmp3 = abs(tmp1 - tmp2);
    T tmp4 = min(tmp1, tmp2);
    return tmp3 + tmp4;
}

template<typename T>
inline T PointDistance3D(T x1, T y1, T z1, T x2, T y2, T z2) {
    return sqrt(square(x2 - x1) + square(y2 - y1) + square(z2 - z1));
}

template<typename T>
inline T Cube(T a) { return a * a * a; }

template<typename T>
inline T RectengularPrism(T a, T b, T c) { return a * b * c; }

template<typename T>
inline T Pyramid(T base, T height) { return (1 / 3) * base * height; }

template<typename T>
inline T Ellipsoid(T r1, T r2, T r3) { return (4 / 3) * PI * r1 * r2 * r3; }

template<typename T>
inline T IrregualarPrism(T base, T height) { return base * height; }

template<typename T>
inline T Sphere(T radius) { return (4 / 3) * PI * radius * radius * radius; }

template<typename T>
inline T CylinderB(T base, T height) { return base * height; } // base and height
template<typename T>
inline T CylinderR(T radius, T height) { return PI * radius * radius * height; } // radius and height
template<typename T>
inline T Cone(T radius, T base, T height) { return (1 / 3) * PI * radius * radius * height; }

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/


int main(void) {
    int n;
    string s;

    Cin(n);
    int a[n];
    int max1 = 0;
    int max2 = 0;
    rep(i, n) {
        Cin(a[i]);
    }
    sort(a,a+n);
    int suma = 0;
    int sumb = 0;
    int c=0;
    for(int i=n-1;i>=0;i--) {
        if (c % 2 == 0) {
            suma += a[i];
            c++;
        }else{
            sumb += a[i];
            c++;
        }
    }

    cout <<  suma - sumb << endl;


    return 0;
}






Measured memory_bytes: 256