func_code_string:   /*  Karmanye vadhikaraste Ma Phaleshu Kadachana | Ma Karmaphalaheturbhurma Te Sangostvakarmani ||*/   //----------------------------------------------------------------------------------------------------------------//      /* this is begining have to survive more and go through long journey*/    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   #include<bits/stdc++.h>   using namespace std;   #define pb push_back   #define vi vector<int>   #define vii vector<vi>   #define vll vector<long long>   #define mx(v) *max_element(v.begin(),v.end())   #define mn(v) *min_element(v.begin(),v.end())   #define st(v) sort(v.begin(),v.end())   #define bg .begin()   #define ed .end()   #define fi first   #define sc second   #define fr(i,l,u) for(i=l;i<u;i++)   #define rfr(i,l,u) for(i=l;i>u;i--)   #define ll long long int   #define lld long long double   #define uld unsigned long long int   #define pii pair<int,int>   #define flash ios_base::sync_with_stdio(0);cin.tie(NULL);   #define mod 1000000007        void solve()   {       ll n,i,x,sum=0,rem=0;       cin>>n;       vi v;       fr(i,0,n)       {           cin>>x;           sum+=x;       }       rem=sum%n;       cout<<(n-rem)*rem<<endl;                 }         int main()   {        int t;      cin>>t;      while(t--) solve();      }