Find the sum that need to be subtracted from total sum
for i in range ( n ) : NEW_LINE INDENT if ( dp [ 0 ] [ i ] > maxm ) : NEW_LINE INDENT maxm = dp [ 0 ] [ i ] NEW_LINE subtractSum = dp [ 1 ] [ i ] NEW_LINE DEDENT elif ( dp [ 0 ] [ i ] == maxm ) : NEW_LINE INDENT subtractSum = min ( subtractSum , dp [ 1 ] [ i ] ) NEW_LINE DEDENT DEDENT