finished matrix_chain