Condition to select the current element
if ( ( i - 2 >= 0 and dp [ i - 2 ] [ j - 1 ] != - sys . maxsize - 1 ) or i - 2 < 0 ) : NEW_LINE INDENT if ( i - 2 >= 0 ) : NEW_LINE INDENT val = a [ i - 1 ] + dp [ i - 2 ] [ j - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT val = a [ i - 1 ] NEW_LINE DEDENT DEDENT