Code not submitting

my code is fine and giving correct output
but still not been submitting
code is:-

#include
using namespace std;
int main() {
int n,i,j,sum=0,sumtemp=0,target,k;
cin>>target;
for(k=1;k<=target;k++)
{
cin>>n;
int a[n];
for(i=0;i<n;i++)
cin>>a[i];
sum=0;
for(i=0;i<n;i++)
{
sumtemp=0;
for(j=i;j<n;j++)
{
sumtemp=sumtemp+a[j];
if(sumtemp>=sum)
sum=sumtemp;

    }
        if(i!=0)                   //now  going from reverse
        {
           for(j=0;j<=i-1;j++)
        {
            sumtemp=sumtemp+a[j];
            if(sumtemp>=sum)
            sum=sumtemp;
        }
        }

    }
      cout<<sum;
}



return 0;

}

You are supposed to solve this question using kadane’s algo only, where initially you will calculate the maximum subarray sum of component 1 using the kadane’s algo as,
int component1=kadane(ar,n);
and then you will reverse the array elements and then calculate the maximum subarray sum for component 2, as
int component2=wrap+kadane(ar,n);, where wrap will be your sum as, wrap=wrap+ar[i];
and then which one of them is bigger will be the maximum circular sum, you can refer to the online pdf hint given in the course as well.