Sum of replicated matrices Given a list of numbers \$[a_1, a_2, ... a_n]\$, compute the sum of all the matrices \$A_i\$ where \$A_i\$ is defined as follows (\$m\$ is the maximum of all \$a_i\$):
$$
\begin{array}{c|cc}
       &amp; 1 &amp; 2 &amp; \cdots &amp; i-1 &amp;  i  &amp; i+1 &amp; \cdots &amp;  n  \\
\hline
1      &amp; 0 &amp; 0 &amp; \cdots &amp;  0  &amp; a_i &amp; a_i &amp; \cdots &amp; a_i \\
2      &amp; 0 &amp; 0 &amp; \cdots &amp;  0  &amp; a_i &amp; a_i &amp; \cdots &amp; a_i \\
\vdots &amp;   &amp; \vdots &amp; &amp; \vdots &amp; &amp; \vdots &amp; &amp; \vdots \\
a_i    &amp; 0 &amp; 0 &amp; \cdots &amp;  0  &amp; a_i &amp; a_i &amp; \cdots &amp; a_i \\
a_{i+1}&amp; 0 &amp; 0 &amp; \cdots &amp;  0  &amp;  0  &amp;  0  &amp; \cdots &amp;  0  \\
\vdots &amp;   &amp; \vdots &amp; &amp; \vdots &amp; &amp; \vdots &amp; &amp; \vdots \\
m      &amp; 0 &amp; 0 &amp; \cdots &amp;  0  &amp;  0  &amp;  0  &amp; \cdots &amp;  0  \\
\end{array}
$$
Example
Given the input [2,1,3,1] we construct the following matrix:
$$
\left[\begin{matrix}
2 &amp; 2 &amp; 2 &amp; 2 \\
2 &amp; 2 &amp; 2 &amp; 2 \\
0 &amp; 0 &amp; 0 &amp; 0 \\
\end{matrix}\right]
+
\left[\begin{matrix}
0 &amp; 1 &amp; 1 &amp; 1 \\
0 &amp; 0 &amp; 0 &amp; 0 \\
0 &amp; 0 &amp; 0 &amp; 0 \\
\end{matrix}\right]
+
\left[\begin{matrix}
0 &amp; 0 &amp; 3 &amp; 3 \\
0 &amp; 0 &amp; 3 &amp; 3 \\
0 &amp; 0 &amp; 3 &amp; 3 \\
\end{matrix}\right]
+
\left[\begin{matrix}
0 &amp; 0 &amp; 0 &amp; 1 \\
0 &amp; 0 &amp; 0 &amp; 0 \\
0 &amp; 0 &amp; 0 &amp; 0 \\
\end{matrix}\right]
=
\left[\begin{matrix}
2 &amp; 3 &amp; 6 &amp; 7 \\
2 &amp; 2 &amp; 5 &amp; 5 \\
0 &amp; 0 &amp; 3 &amp; 3 \\
\end{matrix}\right]
$$
Rules and I/O

you may assume the input is non-empty
you may assume all the inputs are non-negative (0≤)
the input can be a \$1×n\$ (or \$n×1\$) matrix, list, array etc.
similarly the output can be a matrix, list of lists, array etc.
you can take and return inputs via any default I/O format
your submission may be a full program or function

Test cases
[0] -&gt; [] or [[]]
[1] -&gt; [[1]]
[3] -&gt; [[3],[3],[3]]
[2,2] -&gt; [[2,4],[2,4]]
[3,0,0] -&gt; [[3,3,3],[3,3,3],[3,3,3]]
[1,2,3,4,5] -&gt; [[1,3,6,10,15],[0,2,5,9,14],[0,0,3,7,12],[0,0,0,4,9],[0,0,0,0,5]]
[10,1,0,3,7,8] -&gt; [[10,11,11,14,21,29],[10,10,10,13,20,28],[10,10,10,13,20,28],[10,10,10,10,17,25],[10,10,10,10,17,25],[10,10,10,10,17,25],[10,10,10,10,17,25],[10,10,10,10,10,18],[10,10,10,10,10,10],[10,10,10,10,10,10]]
Jelly, 10 5 bytes

ẋ"z0Ä


Try it online!

How it works

ẋ"z0Ä  Main link. Argument: A (array)


       e.g. [2, 1, 3, 1]

ẋ"     Repeat each n in A n times.

       e.g. [[2, 2   ]
             [1      ]
             [3, 3, 3]
             [1      ]]

  z0   Zipfill 0; read the result by columns, filling missing elements with 0's.

        e.g. [[2, 1, 3, 1]
              [2, 0, 3, 0]
              [0, 0, 3, 0]]

    Ä  Take the cumulative sum of each row vector.

       e.g. [[2, 3, 6, 7]
             [2, 2, 5, 5]
             [0, 0, 3, 3]]