Rank of the $n \times n$ matrix with ones on the main diagonal and $a$ off the main diagonal I want to find the rank of this $n\times n$ matrix
\begin{pmatrix}
1 & a & a & \cdots & \cdots & a \\
a & 1 & a & \cdots & \cdots & a \\
a & a & 1 & a & \cdots & a \\
\vdots & \vdots & a& \ddots & & \vdots\\
\vdots & \vdots & \vdots & & \ddots & \vdots \\
a & a & a & \cdots  &\cdots & 1
\end{pmatrix}
that is, the matrix whose diagonals are $1's$ and $a$ otherwise, where $a$ is any real number.
My first observation is when $a=0$ the rank is $n$ and when $a=1$ the rank is $1.$ Then I can assume $a\neq 0, 1$ and proceed row reduction to find its pivot rows. I obtain
\begin{pmatrix}
1 & a & a & \cdots  & a \\
0 & 1+a & a & \cdots & a \\
0 & a & 1+a & \cdots & a \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
0 & a & a & \cdots  & 1+a
\end{pmatrix}
by subtracting the first row multiplied $a$ for each row below the first, and then divides the factor $(1-a)$, 
and stuck there. Any hints/helps?

If you haven't figured it out yet here's the solution: if $a=1$ $\mathrm{Rank}(A)=1$ otherwise $\mathrm{Rank}(A)=n$ where 
$$A:= \begin{pmatrix}
1&a&a&\cdots&a\\
a&1&a&\cdots&a\\
a&a&1&\cdots&a\\
\vdots&\vdots&\vdots&\ddots&\vdots\\
a&a&1&\cdots&1
\end{pmatrix}$$
You've already shown that you know if $a\in\{0,1\}$. So as for the rest, your close to a solution. The next set of Row equations are as follows $R_i-R_1 \to R_i$ such that $1<i\leq n$. This gives the matrix,
$$A_2= \begin{pmatrix}
1&a&a&\cdots&a\\
-1&1&0&\cdots&0\\
-1&0&1&\cdots&0\\
\vdots&\vdots&\vdots&\ddots&\vdots\\
-1&0&0&\cdots&1
\end{pmatrix}$$
The next Row equation is $\frac{R_1-\sum_{i=2}^n aR_i}{1+a(n-1)}\to R_1$. This gives the matrix
$$A_3= \begin{pmatrix}
1&0&0&\cdots&0\\
-1&1&0&\cdots&0\\
-1&0&1&\cdots&0\\
\vdots&\vdots&\vdots&\ddots&\vdots\\
-1&0&0&\cdots&1
\end{pmatrix}$$
The next Row equations are $R_i+R_1\to R_i$ where $1<i\leq n$. This gives
$$A_4= \begin{pmatrix}
1&0&0&\cdots&0\\
0&1&0&\cdots&0\\
0&0&1&\cdots&0\\
\vdots&\vdots&\vdots&\ddots&\vdots\\
0&0&0&\cdots&1
\end{pmatrix}=I$$
Note that $\mathrm{Rank}(A)=\mathrm{Rank}(I)=n$ as desired. 
Karma made note that if $a=\frac{1}{1-n}$ then 
$$A_3= \begin{pmatrix}
0&0&0&\cdots&0\\
-1&1&0&\cdots&0\\
-1&0&1&\cdots&0\\
\vdots&\vdots&\vdots&\ddots&\vdots\\
-1&0&0&\cdots&1
\end{pmatrix}$$
This implies that for $a=\frac{1}{1-n}$ the $\mathrm{Rank}(A)=n-1$.
