Question: 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?**

Answer: 
We have $M = D - e e^T$, where $D$ is a block diagonal matrix with main diagonals equal to $D\_i = \mathrm{diag}(a\_i) + 2 J\_i$, and $e$ is all ones vector with suitable dimention. By [Matrix determinant lemma](https://en.wikipedia.org/wiki/Matrix_determinant_lemma) we have
$$\det(M) = (1- e^TD^{-1}e) \det(D)$$
and
$$\det(D) = \prod\_i\det(D\_i) = \prod\_i (1+ 2\frac{n\_i}{a\_i})a\_i^{n\_i}$$
Also, by [Sherman–Morrison formula](https://en.wikipedia.org/wiki/Sherman%E2%80%93Morrison_formula), we have

$$D\_i^{-1} = \mathrm{diag}(a\_i^{-1}) - \frac{2\mathrm{diag}(a\_i^{-1})J\_i\mathrm{diag}(a\_i^{-1})}{1+2 n\_i/a\_i}$$. So, 

$$1-e^TD^{-1}e = 1- \sum\_i\frac{n\_i}{a\_i} + \sum\_i \frac{2(n\_i/a\_i)^2}{1+2 n\_i/a\_i} = \sum\_i \frac{1+ n\_i/a\_i}{1+2n\_i/a\_i}$$
Therefore 
$$\det(M) = (\sum\_i \frac{1+ n\_i/a\_i}{1+2n\_i/a\_i}) \prod\_i (1+ 2\frac{n\_i}{a\_i})a\_i^{n\_i} \\= \prod\_{i=1}^k a\_i^{n\_i} \sum\_{j=0}^k (2-j)2^{j-1}e\_j$$
To complete Mahdi's answer, it suffices to show
$$(1-\sum\_i\frac{x\_i}{1+2x\_i})\prod\_i(1+2x\_i)=\sum\_{j\ge 0} (2-j)2^{j-1}e\_j.$$
Clearly $\prod\_i(1+ax\_i)=\sum\_{j\ge 0} a^je\_j$, which explains the $2^je\_j$ term on the RHS.

Consider $\frac{\partial}{\partial t}\prod\_i(1+x\_i+tx\_i)|\_{t=1}$. On the one hand it is $\sum\_ix\_i\prod\_{k\neq i}(1+2x\_k)$ by product rule, which appears on the LHS. On the other hand it is $\frac{\partial}{\partial t}\sum\_{j\ge 0} (1+t)^{j}e\_j|\_{t=1}=\sum\_{j\ge 0}j2^{j-1}e\_j$, which appears on the RHS.