I want to know what's the problem in my code why it is giving wrong value

#include
#include

using namespace std;

int kaden(int ar[], int n)
{
int cs = 0, ms = 0;
for(int i=0;i<n;i++)
{
cs += ar[i];
if(cs<0)
cs = 0;
ms = max(cs, ms);
}
return ms;
}

int maxSum(int ar[], int n)
{
int c1 = kaden(ar, n);

int sum = 0;
for(int i =0;i<n;i++)
{
    sum += ar[i];
    ar[i] = -ar[i];
}

sum = sum + kaden(ar, n);

return  max(c1, sum);

}

int main()
{
/int a[] = {11, 10, -20, 5, -3, -5, 8, -13, 10};
int n = sizeof(a)/sizeof(a[0]);
cout << "Maximum circular sum is " << maxSum(a, n) << endl;
/

int t;
cin>>t;

for(int i=0;i<t;i++)
{
    int n;
    cin>>n;
    int ar[n];
    for(int j =0;j<n;j++)
        cin>>ar[n];

    cout<<maxSum(ar, n)<<endl;
}


return 0;

}

@Nitishkumar9711 hey nitish see your main function I can see you’re taking value in the array in the wrong manner please fix it and share your code through cb.lk/ide

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.