2500 3
2000 2000 3 3
1000 1500 1500 1 3 3
1000 500 1000 1000 1 2 3 4
0 0 0 0 0
The entry 3 in position (1,5) at the top of the s array means that the matrix chain is parenthesized at the top level as
(A1A2A3)(A4A5)
The entry 1 in position (1,3) of the s array shows how the first factor above is parenthesized. No further parenthesization is needed to disambiguate; the final expression may be written as (A1(A2A3))(A4A5), which does have cost 2500.