1 /*
2 * File: 10137.cpp
3 * Author: GongZhi
4 * Problem: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=29&page=show_problem&problem=1078
5 * Created on 2009年7月25日, 下午9:29
6 */
7
8 #include <stdlib.h>
9 #include <string.h>
10 #include <iostream>
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <queue>
15 using namespace std;
16
17 /*
18 *
19 */
20 double data[2000];
21 char temp[100];
22 int main() {
23 int n,i;
24 double t,ans1,ans2;
25 while(scanf("%d",&n),n){
26 t=0;
27 for(i=0;i<n;i++){
28 scanf("%lf",&data[i]);
29 t+=data[i];
30 }
31 t/=n;
32 sprintf(temp,"%.2f",t);
33 sscanf(temp,"%lf",&t);
34 ans1=0;ans2=0;
35 for(i=0;i<n;i++)
36 if(t>data[i])ans1=ans1+t-data[i];
37 else ans2=ans2-t+data[i];
38 if(ans1<ans2)printf("$%.2f\n",ans1);
39 else printf("$%.2f\n",ans2);
40 }
41 return 0;
42 }
43
44