import std.stdio, std.conv, std.string, std.algorithm, std.range;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.to!(int[]);
    if (N % 2) A ~= 0;
    A.sort!((a,b) => a > b).chunks(2).map!(a => a[0] - a[1]).sum.writeln;
}
