Run time error is there

my code is showing run time error what is it?
#include
using namespace std;
int main() {
int cases;
cin>>cases;
for(int d=1;d<=cases;d++)
{
int n;
cin>>n;
int a[1000];

	for(int i=0;i<n;i++)
    cin>>a[i];

	int maxsofar=a[0];
	int maxending=0;

	for(int i=0;i<n;i++)
	{   maxending=maxending+a[i];
	    maxsofar=max(maxending,maxsofar);
		maxending=max(maxending,0);

	}
	cout<<maxsofar<<endl;
	



}
return 0;

}

hello @himanshu24

use given n to declare array size.

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.