6. (10%) Show that if $A \in \mathbb{M}_n(\mathbb{R})$ and $A^2 = A$, then$$\text{rank}(A) + \text{rank}(I - A) = n.$$