Problem in solving a question of vector space. The question is :
Let, $V$ be the subspace of all real $n \times n$ matrices such that the entries in every row add up to zero and the entries in every column also add up to zero. What is the dimension of $V$?
Now,I find that for $n=2$ the given condition yields a symmetric matrix of order $2$ which generates a subspace of dimension $3$ and for $n=3$ the matrix is not symmetric and the dimension of the corresponding subspace becomes $6$.But I fail to generalise this concept to get my required result. Please help me.Thank you in advance. 
 A: Actually when $n=2$, you should get 1. Suppose we decide to make the top entry $a$. Then the top right and lower left entries must be $-a$. And once we see that, the bottom right entry must be $a$. So $$V = \textrm{span}\left[\begin{pmatrix}
1 & -1 \\
-1 & 1
\end{pmatrix} \right].$$
If $n=3$, you can fill in the the top-left $2\times 2$ sub-matrix without worry.
$$\begin{pmatrix}
a_1 & a_2 & - \\
a_3 & a_4 & - \\
- & - & -
\end{pmatrix}_.$$
Now the conditions tell us that the rest of the entries must be as follows
$$\begin{pmatrix}
a_1 & a_2 & -(a_1+a_2) \\
a_3 & a_4 & -(a_3+a_4) \\
-(a_1+a_3) & -(a_2+a_4) & a_1 + a_2 + a_3 + a_4
\end{pmatrix}_.$$
So we really only had 4 choices to make. That is, $dim(V) = 4$.
A basis for $V$ when $n=3$ is $$ $$\begin{pmatrix}
1 & 0 & -1 \\
0 & 0 & 0\\
-1 & 0 & 1
\end{pmatrix} \begin{pmatrix}
0 & 1 & -1 \\
0 & 0 & 0 \\
0 & -1 & 1
\end{pmatrix} \begin{pmatrix}
0 & 0 & 0 \\
1 & 0 & -1 \\
-1 & 0 & 1
\end{pmatrix} \begin{pmatrix}
0 & 0 & 0 \\
0 & 1 & -1 \\
0 & -1 & 1
\end{pmatrix}
The general pattern is $dim(V) = (n-1)^2$.
You can see this in a similar fashion to the $3\times 3$ case. I.e. Once you fill in the upper-left $(n-1)\times (n-1)$ submatrix, the rest of the matrix is uniquely determined.
A: For an $n\times n$ matrix $A$ such that all of its row entries and column entries add up to zero, you can choose exactly $(n-1)$ rows and from each row you can choose exactly $(n-1)$ entries freely. So, you can totally choose $(n-1)\times(n-1)=n^2-2n+1$ entries freely. Whenever you have chosen these $(n^2-2n+1)$ entries, remaining entries become constrained. 
Hence, dimension of $V$ is $n^2-2n+1$.
For rigorousness, you can try showing that,
$A^{(ij)}=((a^{ij}_{rs}))_{n\times n}$ such that 
$a^{ij}_{ij}=1$, $a^{ij}_{in}=-1$, $a^{ij}_{nj}=-1$ and $a^{ij}_{rs}=0$ otherwise, where, $1\le i,j\le n-1$, form a basis of V.
