Maximize the sum of modulus with every Array element | C # program to find the maximum sum of modulus with every array element ; Function to return the maximum sum of modulus with every array element ; Sum of array elements ; Return the answer ; Driver Code
using System ; class GFG { static int maxModulosum ( int [ ] a , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } return sum - n ; } public static void Main ( String [ ] args ) { int [ ] a = new int [ ] { 3 , 4 , 6 } ; int n = a . Length ; Console . Write ( maxModulosum ( a , n ) ) ; } }