import statistics as st N = int(input()) Y = list(map(int,input().split())) #print(Y) #中央値の算出~距離を算出 median = 0. distance = 0 median = st.median(Y) for i in range(N): distance = distance + abs(median-Y[i]) print(distance)