Proof of the discrete Doob inequality $\mathbf{Theorem:}$ Let $n \in \mathbb{N}, a,b, \in \mathbb{R}, a < b$ and $S_i$ a submartingale for $i=1,2,\dots,n$. Define $$H_n(a,b;S_1,\dots,S_n) = \text{card} \Bigg( \{ (i,j) \in \mathbb{N}^2: 1 \le i <j \le n, S_i \le a, S_j \ge b, a<S_k<b, \forall k = i+1, i+2,\dots, j-1 \} \Bigg)$$ a function that is counting the number of "upward crossings" of the interval $(a,b)$. (i.e. $H_n$ = How many $S_i$ fell below $a$ and then rose above $b$). Then
$$\mathbb{E}[H_n(a,b;S_1,\dots,S_n)] \le \frac{\mathbb{E}(S_n-a)^{+}-\mathbb{E}(S_1-a)^{+}}{b-a} \le \frac{\mathbb{E}(S_n-a)^{+}}{b-a} $$
$\mathbf{Proof:}$ Denote $Z_i = (S_i-a)^{+}$, this way our $H_n(a,b; S_1,\dots,S_n)=H_n(0,b-a; Z_1,\dots,Z_n)$ and define the stopping times $$\Lambda_k=\min\{\min\{i\in \mathbb{N}: i\ge \Psi_{k-1}, Z_i=0\},n\}$$
$$\Psi_k = \min\{ \min \{i\in \mathbb{N}: i \ge \Lambda_{k},  Z_i \ge b-a \},n\}\\ \Psi_0 \equiv 1$$
Now we can proceed proving the Doob inequality:
\begin{align}
Z_n-Z_1 &= Z_{\Lambda_{ \lfloor \frac{n}{2} \rfloor+1} } - Z_{\Psi_0}\\
&= \sum_{i=1}^{\lfloor \frac{n}{2} \rfloor +1} (Z_{\Lambda_k}-Z_{\Psi_{k-1}} )+ \sum_{i=1}^{\lfloor \frac{n}{2} \rfloor} (Z_{\Psi_k}-Z_{\Lambda_{k-1}} )  \\
& \ge \sum_{i=1}^{\lfloor \frac{n}{2} \rfloor} (Z_{\Lambda_{k+1}}-Z_{\Psi_{k}} ) + (b-a)H_n(0,b-a; Z_1,\dots,Z_n) 
\end{align}
Taking the expectation of $Z_n - Z_1$ proves the inequality. $\square$
$\mathbf{Q}$: What I don't understand is the magic around the stopping times. Sure, $\Lambda_k$ denotes the first time after $\Psi_{k-1}$ (i.e. $Z_{k-1}$ rose above $b-a$ ) that $Z_k$ returns back to the origin. Conversely, $\Psi_k$ denotes the first time after $Z_{k-1}=0$ that $Z_k$ exceeded $b-a$. So this is how we play around with the notion of "interval crossing." 
What I don't get, though, is why $Z_n = Z_{\Lambda_{ \lfloor \frac{n}{2} \rfloor+1}}$?? The subscript. Why the integer of $\frac{n}{2}+1$. Is this because we've got one $k$ that's taking care of the "upward" crossing and another $k$ for the "downward" crossing (so in the end for $k$ crossings, a half would be "bottom $\to$ top" and the other "top $\to$ bottom")? 

The equality
$Z_n  = Z_{\Lambda_{\lfloor\frac n2\rfloor + 1}}$
is simply a consequence of the fact that 
$\Lambda_{\lfloor\frac n2\rfloor + 1} = n$ .  
Because there has to be a downcrossing between every two upcrossings we must have $\Lambda_{k+1}\geq\Lambda_k+2$  therefore $\Lambda_{\lfloor\frac n2\rfloor + 1} \geq n$ and equality must hold because $\Lambda_k$ is defined as the minimum of $n$ and the time of the $k$th upcrossing. 
