$M_n(F)$ is the set of all $n\times n$ matrices over field $F$. Suppose $A\in M_n(F)$. Show that: $$A^2=A \iff \text{rank}(A)+\text{rank}(A-I)=n$$ Actually I'm somehow new to linear algebra and I'm not familiar with its techniques. I tried to find row/column spaces of $A$ and $A^2$ or $A-I$ and find their basis. But I wasn't that much successful. Also I tried to connect this problem to linear transformations, but I counldn't find out how.
Any help ot hints is so much appreciated.