Solution (source code)

= Solution

For $n<N$,
$$
A_{n+1}-A_n
=V_n-\mathbb E[V_{n+1}\mid\mathcal F_n]\geq0.
$$
The recursion
$$
V_n=\max\{Z_n,\mathbb E[V_{n+1}\mid\mathcal F_n]\}
$$
shows that if $V_n>Z_n$, then $V_n=\mathbb E[V_{n+1}\mid\mathcal F_n]$ and the increment of $A$ is zero. Conversely, if that increment is positive, the maximum must be attained by $Z_n$, so $V_n=Z_n$. The two nonnegative quantities therefore satisfy
$$
\min\{V_n-Z_n,A_{n+1}-A_n\}=0.
$$
For $n=N$, this also holds because $V_N=Z_N$, regardless of the convention $A_{N+1}=\infty$.