Maximize the sum of modulus with every Array element | Java 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
import java . io . * ; 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 ; System . out . println ( maxModulosum ( a , n ) ) ; } }