1. 

/**
* ACM
* UVa Status: accepted
* Run Time: 0.050
* Category: ad hoc
* @author Evgeni Pavlidis evgenipavlidis@yahoo.de
*/
#include <iostream>
#include <cmath>

using namespace std;

#define MAX_STUDENTS 1000

static double amount[MAX_STUDENTS];

int main()
{
int n;
double average;

while(true)
{
cin >> n;
if(n == 0)
return 0;

double sum = 0;
for(int s=0; s < n; s++)
{
cin >> amount[s];
sum += amount[s];
}
average = sum/n;
average = (int)(average * 100 + 0.5);
average /= 100;

double sumUnder = 0, sumOver = 0;
for(int s=0; s < n; s++)
if(amount[s] < average)
sumUnder += average - amount[s];
else
sumOver += amount[s] - average;


double out = (sumOver < sumUnder)? sumOver : sumUnder;
printf("$%.2lf\n", out);



}
}