Calculate inverse of matrix with -1 on diagonal and 1 on the rest Calculate the inverse of the matrix
\begin{bmatrix}
 -1&  1&  ...&  ...&1 \\ 
 1&  -1&  1& ... &1 \\ 
 ...&  ...&  ...&  ...&1 \\ 
 1&1  &1  &  ...&1 \\ 
 1& 1 &1  &1  &-1 
\end{bmatrix}
$-1$ on the diagonal and $1$ on the rest.
The key I think is to perform a sequence of elementary transformations on 
[ A | $I_{n}$ ] until we get [  $I_{n}$ | $A^{-1}$ ] but that seems to be complicated.
 A: Let $e$ be the all one vector. We have
$$A=-2I+ee^T$$
By Sheman-Morrison formula:
\begin{align}A^{-1}&=(-2I+ee^T)^{-1}\\&=-\frac12I-\frac{-\left(\frac12I\right)ee^T\left(-\frac12I\right)}{1+e^T\left( -\frac12I\right)e} \\
&=-\frac12I-\frac{\frac14ee^T}{1-\frac{n}2} \\
&=-\frac12I-\frac{ee^T}{4-2n}
\end{align}
Hence, the off diagonal entries are $-\frac1{4-2n}$ and the diagonal entries are $-\frac12-\frac1{4-2n}$.
Remark: If $n=2$, the matrix is not invertible.
A: The inverse also has a constant $a$ on the main diagonal and $b$ everywhere else. The constants do depend on the matrix size $n;$ as noted, for $n=2$ there is no inverse. Just try the thing for $n=3$ and $n=4$ and $n=5.$ By that time you should have it, for $n \geq 3$
for $n=3:$
$$
\left(
\begin{array}{rrr}
-1 & 1&1 \\
1 & -1&1 \\
1 & 1&-1 \\
\end{array}
\right)
\left(
\begin{array}{ccc}
a & b&b \\
b & a&b \\
b & b&a \\
\end{array}
\right)=
\left(
\begin{array}{rrr}
1 & 0&0 \\
0 & 1&0 \\
0 & 0&1 \\
\end{array}
\right)
$$
for $n=4,$ different $a,b:$
$$
\left(
\begin{array}{rrrr}
-1 & 1&1&1 \\
1 & -1&1&1 \\
1 & 1&-1&1 \\
1 & 1&1&-1 \\
\end{array}
\right)
\left(
\begin{array}{cccc}
a & b&b&b \\
b & a&b&b \\
b & b&a&b \\
b & b&b&a \\
\end{array}
\right)=
\left(
\begin{array}{rrrr}
1 & 0&0&0 \\
0 & 1&0&0 \\
0 & 0&1&0 \\
0 & 0&0&1 \\
\end{array}
\right)
$$
for $n=5,$ still different $a,b:$
$$
\left(
\begin{array}{rrrrr}
-1 & 1&1&1&1 \\
1 & -1&1&1&1 \\
1 & 1&-1&1&1 \\
1 & 1&1&-1&1 \\
1&1&1&1&-1 \\
\end{array}
\right)
\left(
\begin{array}{ccccc}
a & b&b&b &b\\
b & a&b&b&b \\
b & b&a&b &b \\
b & b&b&a &b \\
b&b&b&b&a \\
\end{array}
\right)=
\left(
\begin{array}{rrrrr}
1 & 0&0&0 &0 \\
0 & 1&0&0&0 \\
0 & 0&1&0 &0 \\
0 & 0&0&1 &0 \\
0&0&0&0&1
\end{array}
\right)
$$
A: It's not too bad...
$$\begin{array}{c}-1\\-1\\\vdots\\*
\end{array}\left[\begin{array}{cccc|cccc}
-1&1&\cdots&1 &1\\
1&-1&\cdots&1 &&1\\
\vdots&\vdots&\ddots&\vdots &&&\ddots\\
1&1&\cdots&-1 &&&&1
\end{array}\right] \implies$$
$$\begin{array}{c}*\\*\\\vdots\\\small 1/2\end{array}
\left[\begin{array}{cccc|cccc}
-2&&&2 &1&&&-1\\
&-2&&2 &&1&&-1\\
&&\ddots& &&&\ddots\\
1&1&&-1 &&&&1
\end{array}\right] \implies$$
$$\begin{array}{c}*\small -1/2\\*\small -1/2\\\vdots\\*\ \small ^1\!/_{\!n-2}\end{array}
\left[\begin{array}{cccc|cccc}
-2&&&2 &1&&&-1\\
&-2&&2 &&1&&-1\\
&&\ddots& &&&\ddots\\
&&&n-2 &\small 1/2&\small 1/2&&\small-^{(n-3)\!}/_{\!2}
\end{array}\right] \implies$$
$$\begin{array}{c}1\\1\\\vdots\\*\end{array}
\left[\begin{array}{cccc|cccc}
1&&&-1 &\small -1/2&&&\small 1/2\\
&1&&-1 &&\small -1/2&&\small 1/2\\
&&\ddots& &&&\ddots\\
&&&1 &\small ^1\!/_{\!2(n-2)}&\small ^1\!/_{\!2(n-2)}&&\small -^1\!/_{\!2}+ ^1\!/_{\!2(n-2)}
\end{array}\right] \implies$$
$$\begin{array}{c}\ \\ \\ \\ \end{array}
\left[\begin{array}{cccc|cccc}
1&&& &\small -^1\!/_{\!2}+ ^1\!/_{\!2(n-2)}&\small ^1\!/_{\!2(n-2)}&\cdots&\small ^1\!/_{\!2(n-2)}\\
&1&& &\small ^1\!/_{\!2(n-2)}&\small -^1\!/_{\!2}+ ^1\!/_{\!2(n-2)}&\cdots&\small ^1\!/_{\!2(n-2)}\\
&&\ddots& &\vdots&\vdots&\ddots&\vdots\\
&&&1 &\small ^1\!/_{\!2(n-2)}&\small ^1\!/_{\!2(n-2)}&\cdots&\small -^1\!/_{\!2}+ ^1\!/_{\!2(n-2)}
\end{array}\right]$$
