Divisible Subarrays Doubt

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {

ll N;
cin >> N;
ll bucket[100];
ll arr[N];
for(ll i=0;i<N;i++){
	cin >> arr[i];
}
ll sum=0;
for(ll i=0;i<N;i++){
	sum+=arr[i];
	sum%=N;
	sum = (sum+N)%N;
	bucket[sum]++;

}
ll ans=0;
for(int i=0;i<=100;i++){
	if(bucket[i]>=2){
		ans = (bucket[i])*(bucket[i]-1)/2;
	}
}
return 0;

}
/bin/run.sh: line 4: 18 Bus error (core dumped) ./exe
what does this mean?

something similar to segmentation fault

y am i gettinng it such type of error

iterate i < N
because the array can be of smaller size

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {

int T;

cin >> T;

while(T–){

ll N;

cin >> N;

ll bucket[1000000]={0};

bucket[0]=1;

ll arr[N];

for(ll i=0;i<N;i++){

cin >> arr[i];

}

ll sum=0;

for(ll i=0;i<N;i++){

sum+=arr[i];

sum%=N;

sum = (sum+N)%N;

bucket[sum]++;

}

ll ans=0;

for(int i=0;i<N;i++){

if(bucket[i]>=2){

ans = (bucket[i])*(bucket[i]-1)/2;

}

}

cout<<ans<<endl;

}

return 0;

}
for the above code i am getting passed only one test case. I am not able to find my mistake.Could you please help me ?

and there is one more doubt
in lecture video we did
sum%=n;sum = (sum+n)%n;//To convert -2 to 2 for example
but let us say sum = -2;
sum = (-2+5)%5 = 3. It won’t work right?

this is correct
but the code will work fine
see
if we see the stmt
a%n == (a+n)%n => a%n + n%n-> a %n + 0
so the answer 3 is correct and it it mapping the the correct/desired +ve value

@dare_devil_007
As you have reopened this doubts, please tell me what problem are you facing.