Matrix Chain Multiplication Cost
Given an array of dimensions `dims` representing matrix chain dimensions, where dims[i-1] and dims[i] are dimensions of matrix i, find the minimum number of scalar multiplications needed to multiply the chain of matrices.