CPP - Maximum Subarray Sum 2

What is the wrong with my code ?
I am not getting the maximum sum.

#include
using namespace std;
int main (){
int n;
cin>>n;
int a[1000];
int currentsum = 0;
int maxsum = 0;
int cumsum[1000]={0};
cin>>a[0];
cumsum[0] = a[0];
for (int i=1; i<n ; i++){
cin>>a[i];
cumsum[i] = cumsum[i-1] + a[i];
for(int j=i; j<n; j++){
currentsum = 0;
currentsum = cumsum[j] - cumsum[i-1];

if(currentsum>maxsum){
maxsum = currentsum;
}
}

}
cout<<"Maximum sum is "<<maxsum<<endl;
return 0;
}

@Riankk Please save the code in coding blocks ide and share its link.
Also the constraints are large, so you should do this in linear time using Kadane’s Algorithm.

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.


you have done two three mistakes
i have correct it you can see

please send link of your code in coding blocks ide


This is my code