What's wrong with my code

Test cases are nit passing

#include<bits/stdc++.h>
using namespace std;

int max_subarray_sum(int a[], int n){
int current_max = 0;
int max_so_far = 0;

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

			max_so_far = max(current_max, max_so_far);
		}
		return max_so_far;
}

int main() {
int t;
cin>>t;

int n;
int a[1000] ={0};
while(t--){
	cin>>n;
	for(int i=0;i<n; i++)
		cin>>a[i];

cout<<max_subarray_sum(a, n)<<"\n";
}	

return 0;
}

@cyberaj123 share it using cb ide

#include<bits/stdc++.h>
using namespace std;

int max_subarray_sum(int a[], int n){
int current_max = 0;
int max_so_far = 0;

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

			max_so_far = max(current_max, max_so_far);
		}
		return max_so_far;
}

int main() {
int t;
cin>>t;

int n;
int a[1000] ={0};
while(t--){
	cin>>n;
	for(int i=0;i<n; i++)
		cin>>a[i];

cout<<max_subarray_sum(a, n)<<"\n";
}	

return 0;
}

@cyberaj123 just inc size to 1e5

please elaborate which size to increase

@cyberaj123 array size 100000 instead of 1000

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.