What is the error in my code please tell!

#include<bits/stdc++.h>
using namespace std;
int factorial(int n)
{
if(n==0)
return 1;
return n*factorial(n-1);
}
int calculate(int n)
{
int de=factorial(n-2)*factorial(2);
int ans=factorial(n)/de;
return ans;
}
int main()
{
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
int arr[n],sum[n+1];

  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
  sum[0]=0;
  for(int i=1;i<n+1;i++)
  {
      sum[i]=sum[i-1]+arr[i-1];
  }
  for(int i=0;i<n+1;i++)
  {
      sum[i]=sum[i]%n;
  }
  map<int,int>mp;
  for(int i=0;i<n+1;i++)
  {
      mp[sum[i]]++;
  }
  int finalans=0;
  map<int,int>::iterator it;
  for(it=mp.begin();it!=mp.end();it++)
  {
      if(it->second>1)
      {
          int temp=it->second;
          finalans +=calculate(temp);
      }
  }
  cout<<finalans<<endl;


}

}

it should be sum[0]= 1

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.