Divisible subarray 3 rd case tle error

#include
using namespace std;
#define ll long long

int main(){
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int a[n];
int b[n+1]={0};
b[0]=1;
int sum=0;
int num=0;
for(int i=0;i<n;i++){
cin>>a[i];
sum=sum+a[i];
num=sum;
num=(num+n)%n;
b[num]++;
}
int ans=0;
for(int i=0;i<n+1;i++){
int m=b[i];
ans=ans+(m*(m-1))/2;
}
cout<<ans<<endl;
}
}

@goelsparsh277,
Please use Coding Blocks IDE to share your codes, look above can you yourself read that untidy code you have shared.

Also, in your code, num can be negative, and you are using it as an array index. Thus it gives runtime error and not TLE.