Calculate the result
if currval in memo : NEW_LINE INDENT if ( currval > 0 ) : NEW_LINE INDENT res = max ( res , currsum - memo [ currval ] + currval ) ; NEW_LINE DEDENT else : NEW_LINE INDENT res = max ( res , currsum - memo [ currval ] + 2 * currval ) ; NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT memo [ currval ] = currsum ; NEW_LINE DEDENT if ( currval < 0 ) : NEW_LINE INDENT currsum = currsum - currval ; NEW_LINE DEDENT