#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
double n;
double a[1005];
while(cin>>n&&n)
{
double sum=0;
double ave=0;
double less=0,greater=0;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
sum=sum+a[i];
ave=sum/n+0.005;
ave=floor(ave*100)/100.0;
for(int i=0;i<n;i++)
if(a[i]>ave) greater+=a[i]-ave;
else less+=ave-a[i];
if(less<greater) {cout<<"$";printf("%.2f\n",less);}
else {cout<<"$";printf("%.2f\n",greater);}
}
return 0;
}