经典题,考察绝对值不等式
def work(n, a):
a.sort()
res = 0
for item in a:
res += abs(item - a[n//2])
return res
if __name__ == '__main__':
N = int(input().strip())
A = list(map(int, input().strip().split()))
ans = work(N, A)
print(ans)