Determinant of a tridiagonal matrix with a superdiagonal of ones and a subdiagonal of minus ones $$ D_n = \begin{vmatrix} a_1 & 1 & 0 & \cdots& 0 & 0\\
-1& a_2 & 1 & \cdots & 0 & 0 \\
0 & -1 & a_3 & \cdots & 0 & 0 \\
\vdots & \vdots & \vdots & \ddots & \vdots & \vdots\\
0 & 0 & 0 & \cdots & a_{n-1} & 1 \\
0 & 0 & 0 & \cdots & -1 & a_n
 \end{vmatrix} $$
I thought to multiply last column with $\frac{1}{a_n}$ and add it to the (n-1)-th column and so on but $a_n$ can be equal to $0$. 

The answer is $$
D_n = \prod_{k=1}^n a_n \left( 1+\sum_{i=1}^{n-1}\frac{1}{a_ia_{i-1}}\right)
$$
The way to do this is to let 
$$
E_n = \frac{D_n}{\prod_{k=1}^n a_n}
$$
and use Achille hui's insight to get 
$$
E_k = E_{k-1}+\frac{1}{a_{k-1}a_{k-2}}
$$
for all $3 \leq k \leq n$ and sum up.  You have to be careful dealing with the endpopints; I think I got them right but you should check this.
