Doubt in the code of maximum subarray cumalative sum

#include
using namespace std;
int main()
{

int n;
cin>>n;
int a[100];
int cumsum[1000]={0};
int maxsum=0;
int currentsum=0;
int left=-1,right=-1;
cin>>a[0];
cumsum[0]=a[0];
for(int i=1;i<n;i++)
{
    cin>>a[i];
    cumsum[i]=a[i]+cumsum[i-1];

}


for(int i=1;i<n;i++)
{


    for(int j=i;j<n;j++)

    {
        currentsum=0;
        currentsum=cumsum[j]-cumsum[i-1];

        if(currentsum>maxsum)
        {
            maxsum=currentsum;
            left=i;right=j;
        }
    }

}
 cout<<"maximum sum of subarray is"<<maxsum<<endl;
for(int k=left;k<=right;k++)
{
   cout<<a[k]<<",";
}

}

what will be the value in the cumsum[i-1 ]array for the first iteration i.e. when i=0 and j=0

it will contain a garbage value which can manipulate the cumalative sum of subarray.???please help

int cumsum[1000]={0};
after this line, all the values of every index of array is zero

can u please answer my question?

please explain your question properly,
may be you want to ask that what will be the value of cumsum[-1] , then answer is it will give segmentation fault

Hey Aman, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.

Aman as u have put value in cumsum[0] which is a[0] and u are starting i =1 therefore it will access the 0 index of cumsum when u do i-1,there will be no garbage value