Computing max of left and right for all temples and returing sum
sm = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT sm += max ( chainSize [ i ] . L , chainSize [ i ] . R ) NEW_LINE DEDENT return sm NEW_LINE