Proof by induction on $n$:
For $n=1$, its obvious;
Suppose its right for $n-1$, then for $n$, there exist an invertible matrix $P$ such that $P^{-1}A_1P=\left(
\begin{array}{cc}
D_1& \\
& 0 \\
\end{array}
\right)$
,where $D_1$ is a diagnol invertible matrix, $P^{-1}A_1PP^{-1}A_i P=P^{-1}A_i PP^{-1}A_1 P=0$
,so $P^{-1}A_i P=\left(
\begin{array}{cc}
0& \\
& D_i \\
\end{array}
\right)$
,where $D_i$ is an low dim matrix and $D_i^2=D_i$ and $D_i D_j=D_j D_i$, so there exist some matrix $Q$ such that $Q^{-1}D_iQ$ are all diagonal, then set $R=P\left(
\begin{array}{cc}
I& \\
& Q \\
\end{array}
\right)$, $R^{-1}A_i R$ are all diagonal.