how prove for n≥2 $0≤\sum_{i=1}^n \sum_{j=1}^na_{ij}≤n $ that $A=[a_{ij}]\in M_n(R)$ be real matrix that A is symmetric and idempotent let $A=[a_{ij}]\in M_n(R)$ be a real, symmetric and idempotent matrix (i.e.$A^2=A$). how can we prove for $n \geq 2$ that 
$$0≤\sum_{i=1}^n \sum_{j=1}^na_{ij}≤n $$ 
thanks in advance. 
 A: As the others have mentioned, $\sum_{i=1}^n \sum_{j=1}^n a_{ij} = {\mathbf 1}^TA{\mathbf 1}$, where $\mathbf 1$ is the vector containing all ones. As ${\mathbf 1}^TA{\mathbf 1}={\mathbf 1}^TA^2{\mathbf 1}={\mathbf 1}^TA^TA{\mathbf 1}=\|A{\mathbf 1}\|^2$, it follows that $\sum_{i=1}^n \sum_{j=1}^n a_{ij}\ge0$.
Now, as $A$ is real symmetric, it can be orthogonally diagonalized as $A=Q^TDQ$, where $Q$ is real orthogonal and $D$ is real diagonal. Since $A^2=A$, we see that $D^2=D$, i.e. each diagonal entry of $D$ is either $0$ or $1$. Therefore ${\mathbf 1}^TA{\mathbf 1}={\mathbf 1}^TQ^TD^2Q{\mathbf 1}=\|DQ\mathbf1\|^2\le\|Q\mathbf1\|^2=\|\mathbf1\|^2=n$.
A: Note that sum $0≤\sum_{i=1}^n \sum_{j=1}^na_{ij}≤n$ can be rewritten as follows
$<A u, u>$ where $u^{T} = (1,1, \cdots ,1)$ where the operation $(\cdot)^T$ is the transpose operation.
For the first part observe $<Au,u>= <A^2u,u>= <Au,A^{T}u> \geq 0$ why?
For the second part since $A$ is real and symmetric there is an orthonormal base of $\mathbb{R^n}$ which consists of his eigenvectors. Then you can write $u$ as a linear combination of those vectors.
Substitute in that equation $<Au,Au>$  with the  previous expression $u$ and by noting that $A^2=A \Rightarrow A(A-I)=0$ So the eigenvalues of $A$ are $0$ or $1$ and conclude.
