unittest
{
	assert( [ "2", "3 1" ].parse.expand.solve == 2 );
	assert( [ "3", "2 7 4" ].parse.expand.solve == 5 );
	assert( [ "4", "20 18 2 18" ].parse.expand.solve == 18 );
}



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

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto alice = 0L;
	auto bob = 0L;
	
	as.sort!( ( a, b ) => b < a );
	
	foreach( i, a; as )
	{
		if( i % 2 == 0 ) alice += a;
		else             bob += a;
	}
	
	return alice - bob;
}
