Given $A$ is an $n \times n$ matrix over the field $F$ with characteristic polynomial
$$f = (x - a_1) ^{d_1} (x-a_2)^{d_2} (x-a_3)^{d_3}...(x-a_k)^{d_k}$$
I have to find the trace of A.
I am thinking:
$$\text{trace of A }= d_1 a_1 + d_2 a_2+...+ d_k a_k$$
Please suggest.