The input is an array of dimensions. If dims = [, , , ], you have matrices: is , is , is .
Matrix i has dimensions . The number of matrices is n = dims.length - . Multiplying matrices i through j (after optimal parenthesization) produces a matrix of size . This fact is key for computing dp[i][j] from smaller ranges. Understanding the problem structure is half the battle.