Traverse the array A
for i in range ( len ( A ) ) : NEW_LINE INDENT if ( currmax < 0 or ( A [ i ] in m and m [ A [ i ] ] == 1 ) ) : NEW_LINE INDENT currmax = 0 NEW_LINE continue NEW_LINE DEDENT currmax = max ( A [ i ] , A [ i ] + currmax ) NEW_LINE DEDENT