Make all groups of similar elements and store the left numbers
for i in range ( 1 , n + 1 ) : NEW_LINE INDENT no_of_groups += v [ i ] // i NEW_LINE v [ i ] = v [ i ] % i NEW_LINE DEDENT i = 1 NEW_LINE total = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE