#include #include #include #include const int MAX_N = (int)1e2+5; int n; int a[MAX_N]; int sum; int avg; int ans; struct Gift{ int next,num; }; std::vector to[MAX_N]; int inDegree[MAX_N]; std::queue q; int main(){ std::ios::sync_with_stdio(false),std::cin.tie(nullptr),std::cout.tie(nullptr); std::cin>>n; for(int i=1;i<=n;i++){ std::cin>>a[i]; sum+=a[i]; } avg = sum/n; ans = 0; for(int i=1;iavg){ int num = a[i]-avg; to[i].push_back({.next=i+1,.num=num}); inDegree[i+1]++; a[i+1]+=num; }else if(a[i]