Perform prefix sum and update the ans to maximum
for i in range ( 1 , MAX ) : NEW_LINE INDENT prefix_sum [ i ] += prefix_sum [ i - 1 ] ; NEW_LINE ans = max ( ans , prefix_sum [ i ] ) ; NEW_LINE DEDENT return ans ; NEW_LINE