#include <iostream>
using namespace std;
int main()
{
int n,t=1;
while(cin>>n && n>0)
{
int a[n],sum=0,ave,mov=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
}ave=sum/n;
for(int i=0;i<n;i++)
if(a[i]>ave)
mov+=a[i]-ave;
cout<<"Set #"<< t++<<"\nThe minimum number of moves is "<<mov<<".\n";
} return 0;
}