#include<stdio.h>
#include<math.h>
const int N = 1010;
double pay[N];
double total_pay(double ave, int n, double sum)
{
double now_tot = 0.0;
double now_ave;
int cnt = 0, i;
now_ave = (int)(ave * 100) / 100.0;
for (i = 0; i < n; i++) {
if ((now_ave + 0.01) < pay[i]) {
now_tot += pay[i] - (now_ave + 0.01);
cnt++;
}
}
if (0.01 * cnt > sum - now_ave * n)
now_tot += now_ave * n + 0.01 * cnt - sum;
return now_tot;
}
int main()
{
int n, i;
double tot, ave;
scanf("%d", &n);
while (n != 0) {
tot = 0;
for (i = 0; i < n; i++) {
scanf("%lf", &pay[i]);
tot += pay[i];
}
ave = tot / n;
printf("$%.2lf\n", total_pay(ave, n, tot));
scanf("%d", &n);
}
return 0;
}