text: Maximize the sum of array after multiplying a prefix and suffix by | C # implementation to find the maximum sum of the array by multiplying the prefix and suffix of the array by - 1 ; Kadane 's algorithm to find  the maximum subarray sum ; Loop to find the maximum subarray array sum in the given array ; Function to find the maximum sum of the array by multiplying the prefix and suffix by - 1 ; Total intital sum ; Loop to find the maximum sum of the array ; Maximum value ; Driver Code
code: using System ; class GFG { static int maxSubArraySum ( int [ ] a , int size ) { int max_so_far = int . MinValue , max_ending_here = 0 ; for ( int i = 0 ; i < size ; i ++ ) { max_ending_here = max_ending_here + a [ i ] ; if ( max_ending_here < 0 ) max_ending_here = 0 ; if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; } return max_so_far ; } static int maxSum ( int [ ] a , int n ) { int S = 0 ; int i ; for ( i = 0 ; i < n ; i ++ ) S += a [ i ] ; int X = maxSubArraySum ( a , n ) ; return 2 * X - S ; } public static void Main ( String [ ] args ) { int [ ] a = { - 1 , - 2 , - 3 } ; int n = a . Length ; int max_sum = maxSum ( a , n ) ; Console . Write ( max_sum ) ; } }