Maximum subarray sum

#include
#include
#include
using namespace std;
int main() {
long long int cursum=0;
long long int arr[100000];
long long int maxsum = 0;
long long int m,n;
cin>>m;
while(m–){
cin>>n;
for(int i=0;i<n;i++){
cin>>arr[i];
}
for(int i=0;i<n;i++){
cursum = cursum + arr[i];
if(cursum < 0){
cursum = 0;
}
maxsum = max(cursum,maxsum);
}
cout<<maxsum<<endl;
}
return 0;
}

i am getting wrong answers in all the testcases .pls tell the correct code

@yutikakhanna can u share u code using coding blocks ide.actually your code is not rendering poperly

@yutikakhanna everything was correct just you need to initialise maxsum=0,cursum=0 for each test cases.
here is your code with bit modifications- https://ide.codingblocks.com/s/173019

@yutikakhanna hey if your doubt is resolved then please mark it resolved