Kadane's algorithm.I am trying to run the same code bt output is always zero

#include

using namespace std;

int main()
{
int n;
cin>>n;
int a[1000];
int cs=0;
int ms=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
//kadane’s algprithm
for(int i=0;i<n;i++)
{
cs=cs+a[i];
if(cs>0){
cs=0;
}

    ms= max(cs,ms);
    
    
}
  cout<<"maximum sumis"<<ms<<endl;
return 0;

}

image
here in the if condition it should be cs < 0 and not cs > 0
rest ur code is fine

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.