Centre of a matrix ring are $ \operatorname{diag}\{ a, a, ..., a \} $ with $ a\in Z(R) $ [duplicate]

Show that $Z(M_n(R))$ consist of $ \operatorname{diag}\{ a, a, ..., a \} $ with $ a\in Z(R) $


Here are some things to think about which should put you in the right direction.

Suppose $A=(a_{ij})\in Z(M_n(R))$. Let $E_{ij}$ be the matrix whose $i,j$ entry is $1$, and all other entries are $0$. Then the equations $$ E_{ii}A=AE_{ii} $$ for $1\leq i\leq n$ implies that $A$ is necessarily diagonal. (Why?) Furthermore, $$ AE_{ij}=E_{ij}A $$ for $1\leq i,j\leq n$ implies that $a_{ii}=a_{jj}$ for all $i$ and $j$. (Why?) Hence $A=aI_n$ for some $a\in R$. But notice that $$ aI_n(bI_n)=bI_n(aI_n),\quad \forall b\in R $$ implies that $a\in Z(R)$.