Make all groups of similar elements and store the left numbers
for ( let i = 1 ; i <= n ; i ++ ) { no_of_groups += Math . floor ( v [ i ] / i ) ; v [ i ] = v [ i ] % i ; } let i = 1 ; let total = 0 ; for ( i = 1 ; i <= n ; i ++ ) {