The following diagram shows the prism with the incoming and outgoing light rays.
If you follow the incident light ray in, it gets bent by an angle $\theta_1 = i- r_1$. If you follow the light ray where it leaves the glass, it gets bent again by an angle $\theta_2 = e - r_2$, so the total deviation is:
$$ \begin{align}
D &= \theta_1 + \theta_2 \\
&= i + e - (r_1 + r_2)
\end{align} $$
For the next step look at the triangle formed by the top of the prism and the light ray, and note that the internal angles must add up to 180°. So:
$$ A + (90 - r_1) + (90 - r_2) = 180 $$
and a quick rearrangement gives:
$$ A = r_1 + r_2 $$
Now substitute for $r_1 + r_2$ in our first equation and we get:
$$ D = i + e - A $$
or:
$$ D + A = i + e $$