Storing sum of array 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" ) ; }