#include
#include
#define ll long
using namespace std;
ll a[1000005],pre[1000005];
int main(){
int t;
cin>>t;
while(t–){
int n;
cin>>n;
memset(pre,0,sizeof(pre));
pre[0]=0;
int sum=0;
for(int i=0;i<n;i++){
cin>>a[i];
sum+=a[i];
sum%=n;
sum=(sum+n)%n; //ans should not be negative
pre[sum]++;
}
ll ans=0;
for(int i=0;i<n;i++){
ll m=pre[i];
ans+=m*(m-1)/2;
}
cout<<ans<<endl;
}
} whats wrong in this code?