Not able to understand solution properly

what is this wrap thing and why are we inverting the array value
can u please elaborate soln

#include
using namespace std;
int kadane(int a[], int n);

int max_circular_sum(int a[], int n)
{

int max_kadane = kadane(a, n);  
// Case 2: Now find the maximum sum that includes  
// corner elements.  
int max_wrap = 0, i;  
for (i = 0; i < n; i++)  
{  
        max_wrap += a[i]; // Calculate array-sum  
        a[i] = -a[i]; // invert the array (change sign)  
}  
  
// max sum with corner elements will be:  
// array-sum - (-max subarray sum of inverted array)  
max_wrap = max_wrap + kadane(a, n);  
  
// The maximum circular sum will be maximum of two sums  
return (max_wrap > max_kadane)? max_wrap: max_kadane; 

}

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

int main() {
int t;
cin>>t;
for(int i=0;i<t;i++){
int n;
cin>>n;
int a[n];
for(int j=0;j<n;j++){
cin>>a[j];
}
cout<<max_circular_sum(a,n)<<endl;
}
return 0;
}

@asifkarim073
the second case is equivalent to taking sum - minsubarray .
You can use kadane to get maximum sum subarray, Now if you multiply the array with -1. and then calculate maximum sum subarray. that subarray would originally be equal to magnitude of minimum sum subarray.