Solution (source code)

= Solution

Pointwise, an integer-valued nonnegative <random variable> has the representation
$$
T=\sum_{n=0}^{\infty}\mathbf1_{\{T>n\}}:
$$
when $T=k$, exactly the terms $n=0,\ldots,k-1$ equal one. Applying the <Tonelli theorem>, or the <monotone convergence theorem> to the finite sums of <indicator random variables>, gives the <tail-sum formula for expectation>
$$
\boxed{\mathbb ET=\sum_{n=0}^{\infty}\mathbb P(T>n).}
$$
Both sides may be infinite; no <integrable random variable>[integrability] assumption is necessary.