hdu2088
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<stdio.h>
2 #include<algorithm>
3 using namespace std;
4 int h[55];
5 int main(){
6 int N,t=0;
7 while(scanf("%d",&N)!=EOF&&N!=0){
8
9 int sum=0,q;
10 for(q=1;q<=N;q++){
11 scanf("%d",&h[q]);
12 sum+=h[q];
13 }
14 if(t++){printf("
");}
15 int ave=sum/N;
16 sort(h+1,h+N+1);
17 int t=0;
18 for(q=N;h[q]>ave;q--)t+=(h[q]-ave);
19 printf("%d
",t);
20 }
21 return 0;
22 }