text: Minimum value to be assigned to the elements so that sum becomes greater than initial sum | Java implementation of the approach ; Function to return the minimum required value ; Find the sum of the array elements ; Return the required value ; Driver code
code: class GFG { static int findMinValue ( int arr [ ] , int n ) { long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; return ( ( int ) ( sum / n ) + 1 ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 4 , 2 , 1 , 10 , 6 } ; int n = arr . length ; System . out . print ( findMinValue ( arr , n ) ) ; } }