Maximum Circular array sum

This is my code. It is giving error in first test case on hackerblock. Please identify the mistake

#include<bits/stdc++.h>
using namespace std;
int kadane(int a[],int n)
{
int i,sum=0,tempsum=0;
for(i=0;i<n;i++)
{
tempsum=max(tempsum+a[i],a[i]);
sum=max(tempsum,sum);
}
return sum;
}
int main() {
int t;
cin>>t;
int n,i,csum;
int candidate1,candidate2;
for(i=0;i<t;i++)
{
cin>>n;
int arr[n];
csum=0;
for(int j=0;j<n;j++)
cin>>arr[j];
candidate1=kadane(arr,n);
//cout<<candidate1<<endl;
for(int j=0;j<n;j++)
{
csum+=arr[j];
//change +ve to -ve and vice versa
arr[j]=-arr[j];
}
//cumulative sum - most -ve part of the original array
candidate2= csum +kadane(arr,n); //csum- (-kadane(arr,n));
//cout<<csum<<" "<<candidate2<<endl;
cout<<max(candidate1,candidate2);
}
return 0;
}