TITLE: Determinant of a block matrix with many $-1$'s
QUESTION [9 upvotes]: For an array $(n_1,...,n_k)$ of non-negative integers and non-zero reals $a_1,...,a_k$, define a block matrix $M$ of size $n=n_1+\cdots+n_k$ as follows:
The main diagonal has blocks of sizes $n_i$ and shapes $$M_i=J_{n_i}+a_i I_{n_i}=\begin{pmatrix}  
a_i+1&1&\cdots&1\\
1&a_i+1&\ddots&\vdots\\
\vdots&\ddots&\ddots&1\\
1&1&1&a_i+1\\
\end {pmatrix}$$ and all the other entries are $-1$.
Experimentally I have found $$\det(M)= \prod_{i=1}^k a_i^{n_i}\sum_{j=0}^k(2-j)2^{j-1}e_j =\prod a_i^{n_i}(1+e_1-4e_3-16e_4-48e_5-\cdots),$$
where $e_j$ is the $j^{th}$ elementary symmetric function of $\dfrac{n_1}{a_1},\dots,\dfrac{n_k}{a_k}$.
It should be a bit technical but not too hard to prove that by induction, but is there a more elegant way?

REPLY [2 votes]: Alternatively, one may just inspect the eigenvalues (whose product is the determinant).
Clearly, all the vectors whose support lies in the $i$th block, and whose coordinates sum up to $0$, are eigenvectors with eigenvalue $a_i$; hence $a_i$ is the eigenvalue with multiplicity (at least) $n_i-1$.
An invariant complement to the sum of already found subspaces is the set $V$ of all block-constant vectors; so we need to check the determinant of the restriction onto $V$. A natural base in $V$ consists of the vectors havig ones in the $i$th block, and zeroes elsewhere. The matrix in this base is 
$$
  A=\left(
  \begin{array}{ccccccccc}
    n_1+a_1& -n_2& -n_2& \cdots& -n_k\\
    -n_1& n_2+a_2& -n_3& \cdots& -n_k\\
    -n_1& -n_2& n_3+a_3& \cdots& -n_k\\
     \vdots& \vdots& \vdots& \ddots& \vdots\\
     -n_1& -n_2& -n_3& \cdots& n_k+a_k
  \end{array}
  \right),
$$
whose determinant is $n_1n_2\dots n_k$ times the determinant of
$$
  B=\left(
  \begin{array}{ccccccccc}
    1+a_1/n_1& -1& -1& \cdots& -1\\
    -1& 1+a_2/n_2& -1& \cdots& -1\\
    -1& -1& 1+a_3/n_3& \cdots& -1\\
     \vdots& \vdots& \vdots& \ddots& \vdots\\
     -1& -1& -1& \cdots& 1+a_k/n_k
  \end{array}
  \right).
$$
Its determinant may be computed either directly, or via the same Matrix determinant lemma, yielding
$$
  \det B=\prod_{i=1}^k\left(2+\frac{a_i}{n_i}\right)
    -\sum_{i=1}^k
      \prod_{\textstyle{1\leq j\leq k\atop j\neq i}}
         \left(2+\frac{a_j}{n_j}\right).
$$
After substituting into
$$
  \det M=\det B\cdot \prod_{i=1}^k n_ia_i^{n_i-1}
$$
and expanding the brackets, we get the desired result. (Although, I would admit, the form it has been obtained in does not look much worse for me.)