#include<stdio.h>
#include<stdlib.h>
int main(){
int *p,n,average,count,i,sum,m;
m = 1;
while(1){
scanf("%d",&n);
if(n == 0) break;
p = (int *)malloc(n*sizeof(int));
for(i = 0,sum = 0;i<n;i++){
scanf("%d",&p[i]);
sum += p[i];
}
average = sum / n;
for(i = 0,count = 0;i<n;i++)
{
if(average - p[i] > 0) count += average - p[i];//计算最小步方法,即为不足移到平均,需要步数
}
printf("Set #%d\nThe minimum number of moves is %d.\n\n",m,count);
m++;
}
return 0;
}