Minimum numbers to be appended such that mean of Array is equal to 1 | Java program for the above approach ; Function to calculate minimum Number of operations ; Storing sum of array arr [ ] ; Driver Code ; Function Call
import java . io . * ; class GFG { static void minumumOperation ( int N , int arr [ ] ) { int sum_arr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum_arr += arr [ i ] ; } if ( sum_arr >= N ) System . out . println ( sum_arr - N ) ; else System . out . println ( "1" ) ; } public static void main ( String [ ] args ) { int N = 4 ; int arr [ ] = { 8 , 4 , 6 , 2 } ; minumumOperation ( N , arr ) ; } }