Prefix Array to Maintain Sum of log values till index i
prefixsum = [ 0 ] * N NEW_LINE prefixsum [ 0 ] = Arraynew [ 0 ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT prefixsum [ i ] = prefixsum [ i - 1 ] + Arraynew [ i ] NEW_LINE DEDENT