My code is showing run time arror

#include
using namespace std;
int main() {
int t;
cin>>t;
for (int j = 0; j < t; j++){
int n, a[1000], max_sum = 0, current_sum = 0;
cin>>n;
for (int i = 0; i < n; i++){
cin>>a[i];
}
for (int i = 0; i < n; i++){
current_sum = current_sum + a[i];
if (current_sum < 0){
current_sum = 0;
}
if (current_sum > max_sum){
max_sum = current_sum;
}
}
cout<<max_sum<<endl;
}
return 0;
}

@coe17b030 hey shubham use inbuilt max function.

The same error still persists

@coe17b030 hey shubham share your saved code here I will debug your code please share the link of the ide of coding blocks ide you can save your code here ide.codingblocks.com

@coe17b030 hey shubham increase the size of the array and do use inbuilt max function.

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.