Error in test case 0 for max circular sum

This is the logic I have. It passes all test cases except case 0. What changes are needed?

while(t–){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
int ans,sum=0;
for(int i=0;i<n;i++){
a[i]*=-1;
}
for(int i=0;i<n;i++)
sum+=a[i];

int cs=0,ms=0;
for(int i=0;i<n;i++){
	cs+=a[i];

	if(cs<0)
	cs=0;

	ms=max(ms,cs);
}
ans=(sum-ms)*(-1);
	cout<<ans<<endl;

@sonalbera
for the test case:
5
-5 3 4 -2 1
ur answer will be 6
required 7

what modifications are needed to clear all errors?

Before making all elements negative find max subarray sum by kadane algo and compare this result at end