void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.math; int n; rd(n); auto a=readln.split.to!(long[]); sort(a); auto md=a[n/2]; writeln(reduce!((r, e)=>r+(e-md).abs)(0L, a)); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x){ e=l[i].to!(typeof(e)); } } void wr(T...)(T x){ import std.stdio; foreach(e; x) stderr.write(e, " "); stderr.writeln; }