Divisible subarrays(one test case fail)

#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
int main(){
int t;
cin>>t;
while(t-- ){
int n ;
cin>>n;
ll arr[n];
for(int i=0; i<n; i++){
cin>>arr[i];
}

	ll ans [n];
	ans[0]=1;
	for(int i=1; i<n; i++) {
		ans[i]=0;
	}
	long sum =0;
	
	for (int i = 0; i < n; i++) {
		sum += arr[i ];
		if (sum < 0) {
			int p = (int)((sum + n) % n);
			ans[p]++;
		} else
			ans[(int) (sum % n)]++;
	}
	ll fs =0;
	for (int i = 0; i < n; i++) {
		if (ans[i] >= 2) {
			fs = fs + ((ans[i] * (ans[i] - 1)) / 2);
		}
	}
	cout<<fs<<endl;
}

}