We have given a square integrable martingale $(M_n)_{n\in \mathbb{N}}$ with $M_0=0$. Then one derives using Jensen's inequality that $(M_n^2)_{n\in \mathbb{N}}$ is a submartingale, of which we assume the Doob decomposition to be $M_n^2 = X_n + A_n$, where $(X_n)_{n\in \mathbb{N}}$ is again a martingale and $(A_n)_{n\in \mathbb{N}}$ a non-decreasing, predictable process with $A_0 = 0$. Furthermore the stopping time $\tau_a = \inf\{n\geq0; A_{n+1}>a^2\}$ was defined.
Now I find in my notes the assertion that, for an $N\in\mathbb{N}$ $ E\left[M_{\min\{N,\tau_a\}}^2\right] = E\left[A_{\min\{N,\tau_a\}}\right] $ which isn't clear to me. In the text it is justified by the argument that $M_{\min\{n,\tau_a\}}^2-A_{\min\{n,\tau_a\}}$ is a martingale (namely $X_{min\{n,\tau_a\}}$ by the optional stopping theorem and Doob's decomposition) with $M_{\min\{0,\tau_a\}}^2-A_{\min\{0,\tau_a\}}=0$. But I don't see how this implies the statement. I'm probably just missing an easy fact here, but can someone shed light on this?