Program is running for custom inputs but giving run time error for submission.
#include
#include
using namespace std;
int main() {
long long int t,sum=0,a[1000],n,i;
long long int max=INT_MIN;
cin>>t;
while(t–)
{
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n;i++)
{
sum+=a[i];
if(sum>max)
max=sum;
if(sum<0)
sum=0;
}
cout<<max<<endl;
sum=0;
max=0;
}
return 0;
}