I am not able to understand why my code is failing the test case

#include
using namespace std;
int main()
{
int a[100004]={0};
int n;
int t;
int cs=0;
int ms=0;
cin>>t;
while(t>0)
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
cs = cs+a[i];
if(cs<0)
{
cs=0;
}
ms=max(cs,ms);
}
cout<<ms<<endl;
t–;
}
return 0;
}

@harshulgarg21 For every test case initialize cs and ms with 0. i.e, cs = 0 and ms = 0 inside the test cases loop.
Hope this helps.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.