Question- Modulo Sum(Pigeonhole)

My code fails in one test case.
Can someone please help! Where am I going wrong?

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int preSum[1005];

int main(){

int n;
cin>>n;

int m;
cin>>m;

ll arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];

memset(preSum,0,sizeof preSum);
int sum=0;
preSum[0] = 1;
for(int i=0;i<n;i++){
sum=sum+arr[i];
sum = sum%m;
sum = (sum+m)%m;

preSum[sum]++;

}
bool found=false;
for(int i=0;i<m;i++){
if(preSum[i]>1)
found=true;
}

if(found)
cout<<“YES”;
else
cout<<“NO”;
}

You have taken sum as a variable of int datatype.
You should change that long long or else you can store each the modulo of each element with m in the original array and then calculate presum with modulo at each step.