Now , perform the following operations : accumulate values in the ' sum [ ] ' array and then add them to the corresponding indexes in 'arr[]
arr [ 0 ] += sum [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT sum [ i ] += sum [ i - 1 ] NEW_LINE arr [ i ] += sum [ i ] NEW_LINE DEDENT