Iterate through all possible values of k in range [ i + 1 , j - 1 ]
for k in range ( i + 1 , j , 1 ) : NEW_LINE INDENT dp [ i ] [ j ] = max ( dp [ i ] [ j ] , dp [ i ] [ k ] + dp [ k ] [ j ] + A [ i ] * A [ j ] ) NEW_LINE DEDENT