http://ybt.ssoier.cn:8088/problem_show.php?pid=1320
#include<bits/stdc++.h>
using namespace std;
int a[661];
int main()
{
int n,sum=0,eve,ans=0;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
sum+=a[i];
}
eve=sum/n;
for(int i=1;i<=n;i++) a[i]-=eve;
int st=1,ed=n;
while(a[st]==0&&st<=ed) st++;
while(a[ed]==0&&st<=ed) ed--;
for(int i=st;i<=ed;i++)
{
if(a[i]==0) continue;
a[i+1]+=a[i];
a[i]=0;
ans++;
}
cout<<ans;
return 0;
}```