AdvancedRating 1900
Matrix Chain Order
Matrices A1...Ak have dimensions d0×d1, d1×d2, ..., d(k−1)×dk. Print the minimum number of scalar multiplications to compute the product.
Input
k+1, then the k+1 dimensions.
Output
A number.
Sample 1
Input
4 10 30 5 60
Output
4500
Sample 2
Input
3 10 20 30
Output
6000
Output appears here