#include <bits/stdc++.h>
using namespace std;
int a[100];
int main()
{
int n,sum=0,num=0;
cin>>n;
for(int i=1;i<=n;++i)
{
cin>>a[i];
}
for(int i=1;i<=n;++i) sum+=a[i];
num=sum/n;
int aum = 0;
for(int i=1;i<=n;++i) aum+=abs(a[i]-num);
cout<<aum/2;
return 0;
}