I'm studying Lie algebra in English and it's not my language.. I'm trying to read about it more but there're lot of things I don't understand. I will be happy if someone know how to do this question cause I really don't have a clue how to start. A hint will be great as well, just need a direction.
Thanks a lot!!!

Let $f\in\hom_L(M,M)$. If $i\in\{1,2,\ldots,n\}$ and if $N$ is one of the copies of $M_i$ inside $M$, then $\ker f|_N$ is a submodule of $N$. Since $N$ is irreducible, $\ker f|_N$ is either $N$ or $\{0\}$. And if $\ker f|N=\{0\}$, then $f(N)$ will be another copy of $M_i$ inside $M$. So, $f\left(M_i^{d_i}\right)\subset M_i^{d_i}$. The dimension of $\hom_L\left(M_i^{d_i},M_i^{d_i}\right)$ is ${d_i}^2$ and therfore$$\dim\hom_L(M,M)=\sum_{i=1}^n{d_i}^2.$$