I remove the run error but getting a wrong answer

#include //kadane algo
using namespace std;
int main()
{
int t;
long int N;
int cs=0,ms=0;
cin>>t;
for(int i=0;i<t;i++)
{cin>>N;
long long int a[N];
for(int j=0;j<N;j++)
{cin>>a[j];
}
for(int j=0;j<N;j++)
{cs=cs+a[j];
if(cs<0){
cs=0;}
ms=max(cs,ms);
}
cout<<ms<<endl;
}
return 0;

}

@bhavyajain hey bhavya do one thing in you code take long long int as data type. and one more thing is that declare int ms and cs variable after first loop which is for(int i=0;i<t;i++)
.I think this creating issue or may be it is taking some garabge value

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.