I have a $n \times n$ matrix $A$ with a full set of eigenvalues $\lambda$ including repetitions. 

I want to create the following $i \times i$ matrix:

$$\left(\sum\_{a=2}^i (a-1) |a-1⟩⟨a| \right) + \sum\_{j=1}^i d\_j 
 \sum\_{b=j}^i |b⟩⟨b-j+1| $$

where $|1⟩,...,|i⟩$ is the standard basis and $d\_j (\lambda) = \sum\_{c=1}^n \lambda\_c^j$.

Any help with coding this matrix in Mathematica would be greatly appreciated.