[proofplan]
We identify the distribution of the [quantile function](/page/Quantile%20Function) by computing its superlevel sets. The key point is the inverse relation $Q_X(p)\le t$ iff $p\le F_X(t)$, whose nontrivial direction uses right-continuity of the distribution function. This gives $\mathcal L^1(\{p:Q_X(p)>t\})=\mathbb P(X>t)$ for every $t\ge0$. Finally, applying the nonnegative layer-cake identity, proved here from Tonelli's theorem, to both $Q_X$ and $X$ gives the equality of the two extended expectations.
[/proofplan]
[step:Show that the generalized quantile is monotone and measurable]
For $0<p\le q<1$, define $A_p:=\{x\in[0,\infty):F_X(x)\ge p\}$ and $A_q:=\{x\in[0,\infty):F_X(x)\ge q\}$. Since $X$ is finite-valued and nonnegative, $F_X(x)\to1$ as $x\to\infty$; hence $A_p$ and $A_q$ are nonempty subsets of $[0,\infty)$. Since $p\le q$, one has $A_q\subset A_p$. Taking infima in $[0,\infty]$ gives
\begin{align*}
Q_X(p)=\inf A_p\le \inf A_q=Q_X(q).
\end{align*}
Thus $Q_X$ is nondecreasing on $(0,1)$.
Because every monotone extended-real-valued function on an interval is Borel measurable, the restriction $Q_X|_{(0,1)}:(0,1)\to[0,\infty]$ is Borel measurable. The endpoint values at $0$ and $1$ alter the function only on the two-point set $\{0,1\}$, and $\mathcal L^1(\{0,1\})=0$, so $Q_X:[0,1]\to[0,\infty]$ is $\mathcal B([0,1])$-measurable.
[/step]
[step:Relate quantile sublevel sets to values of the distribution function]
We prove that for every $t\in[0,\infty)$ and every $p\in(0,1)$,
\begin{align*}
Q_X(p)\le t \quad \Longleftrightarrow \quad p\le F_X(t).
\end{align*}
First suppose $p\le F_X(t)$. Then $t\in\{x\in[0,\infty):F_X(x)\ge p\}$, and therefore the infimum defining $Q_X(p)$ satisfies $Q_X(p)\le t$.
Conversely, suppose $Q_X(p)\le t$. Let $A_p:=\{x\in[0,\infty):F_X(x)\ge p\}$. As above, $A_p$ is nonempty because $F_X(x)\to1$ as $x\to\infty$. For every $\varepsilon>0$, the inequality $Q_X(p)\le t<t+\varepsilon$ and the definition of the infimum imply that there exists $x_\varepsilon\in A_p$ with $x_\varepsilon<t+\varepsilon$. Since $F_X$ is nondecreasing,
\begin{align*}
p\le F_X(x_\varepsilon)\le F_X(t+\varepsilon).
\end{align*}
The right-continuity of $F_X$ at $t$ follows from continuity from above of the probability measure $\mathbb P$: the events $\{\omega\in\Omega:X(\omega)\le t+\varepsilon\}$ decrease to $\{\omega\in\Omega:X(\omega)\le t\}$ as $\varepsilon\downarrow0$. Letting $\varepsilon\downarrow0$ gives
\begin{align*}
p\le \lim_{\varepsilon\downarrow0}F_X(t+\varepsilon)=F_X(t).
\end{align*}
This proves the equivalence.
[guided]
The direction $p\le F_X(t)\implies Q_X(p)\le t$ is immediate from the definition: if $F_X(t)$ has already reached level $p$ by time $t$, then $t$ belongs to the set whose infimum defines $Q_X(p)$. Formally, set $A_p:=\{x\in[0,\infty):F_X(x)\ge p\}$. The condition $p\le F_X(t)$ says $t\in A_p$, hence
\begin{align*}
Q_X(p)=\inf A_p\le t.
\end{align*}
The reverse direction is where right-continuity is needed. The statement $Q_X(p)\le t$ says that the infimum of $A_p$ lies at or before $t$, but it does not by itself say that $t\in A_p$. We first note that $A_p$ is nonempty: since $X$ is finite-valued and nonnegative, the events $\{\omega\in\Omega:X(\omega)\le x\}$ increase to $\Omega$ as $x\to\infty$, so continuity from below gives $F_X(x)\to1$; because $p<1$, some $x\in[0,\infty)$ satisfies $F_X(x)\ge p$. At a jump, the infimum might be approached from the right. To bridge that gap, fix $\varepsilon>0$. Since $t+\varepsilon$ is strictly larger than the infimum $Q_X(p)$, there exists some $x_\varepsilon\in A_p$ such that
\begin{align*}
x_\varepsilon<t+\varepsilon.
\end{align*}
By membership in $A_p$,
\begin{align*}
p\le F_X(x_\varepsilon).
\end{align*}
Since $F_X$ is nondecreasing and $x_\varepsilon<t+\varepsilon$, we have
\begin{align*}
F_X(x_\varepsilon)\le F_X(t+\varepsilon).
\end{align*}
Combining these inequalities gives
\begin{align*}
p\le F_X(t+\varepsilon)
\end{align*}
for every $\varepsilon>0$. Finally, $F_X$ is right-continuous at $t$: the events $\{\omega\in\Omega:X(\omega)\le t+\varepsilon\}$ decrease to $\{\omega\in\Omega:X(\omega)\le t\}$ as $\varepsilon\downarrow0$, and continuity from above of $\mathbb P$ applies because $\mathbb P(\Omega)=1<\infty$. Therefore
\begin{align*}
\lim_{\varepsilon\downarrow0}F_X(t+\varepsilon)=F_X(t).
\end{align*}
Passing to this limit yields $p\le F_X(t)$, completing the proof of
\begin{align*}
Q_X(p)\le t \quad \Longleftrightarrow \quad p\le F_X(t).
\end{align*}
[/guided]
[/step]
[step:Compute the superlevel measure of the quantile function]
Fix $t\in[0,\infty)$. By the previous step, for $p\in(0,1)$,
\begin{align*}
Q_X(p)>t \quad \Longleftrightarrow \quad p>F_X(t).
\end{align*}
The endpoint values at $p=0$ and $p=1$ do not affect [Lebesgue measure](/page/Lebesgue%20Measure). Hence
\begin{align*}
\mathcal L^1(\{p\in[0,1]:Q_X(p)>t\})
=
\mathcal L^1((F_X(t),1)).
\end{align*}
Since $F_X(t)\in[0,1]$,
\begin{align*}
\mathcal L^1((F_X(t),1))=1-F_X(t).
\end{align*}
By the definition of $F_X$,
\begin{align*}
1-F_X(t)
=
\mathbb P(\{\omega\in\Omega:X(\omega)>t\}).
\end{align*}
Therefore, for every $t\in[0,\infty)$,
\begin{align*}
\mathcal L^1(\{p\in[0,1]:Q_X(p)>t\})
=
\mathbb P(\{\omega\in\Omega:X(\omega)>t\}).
\end{align*}
[/step]
[step:Apply the nonnegative layer-cake identity to both sides]
We use the following nonnegative layer-cake identity. If $(E,\mathcal E,\mu)$ is a [measure space](/page/Measure%20Space) and $f:E\to[0,\infty]$ is measurable, then
\begin{align*}
\int_E f(y)\,d\mu(y)
=
\int_{[0,\infty)}\mu(\{y\in E:f(y)>t\})\,d\mathcal L^1(t).
\end{align*}
Indeed, for every $y\in E$,
\begin{align*}
f(y)=\int_{[0,\infty)}\mathbb 1_{\{t<f(y)\}}\,d\mathcal L^1(t).
\end{align*}
Define the function $H:E\times[0,\infty)\to[0,\infty]$ by $H(y,t):=\mathbb 1_{\{t<f(y)\}}$. To verify measurability, observe that
\begin{align*}
\{(y,t)\in E\times[0,\infty):t<f(y)\}
=
\bigcup_{r\in\mathbb Q\cap[0,\infty)}\{y\in E:f(y)>r\}\times([0,r)\cap[0,\infty)).
\end{align*}
Each set $\{y\in E:f(y)>r\}$ belongs to $\mathcal E$ because $f$ is measurable, and each set $[0,r)\cap[0,\infty)$ belongs to $\mathcal B([0,\infty))$; the displayed countable union is therefore product-measurable. Hence $H$ is measurable and nonnegative, so Tonelli's theorem gives
\begin{align*}
\int_E f(y)\,d\mu(y)
=
\int_{[0,\infty)}\int_E \mathbb 1_{\{f(y)>t\}}\,d\mu(y)\,d\mathcal L^1(t).
\end{align*}
The inner integral equals $\mu(\{y\in E:f(y)>t\})$, proving the identity in the extended nonnegative sense.
Apply this identity first to the measure space $([0,1],\mathcal B([0,1]),\mathcal L^1)$ and the measurable function $Q_X:[0,1]\to[0,\infty]$. We obtain
\begin{align*}
\int_{[0,1]} Q_X(p)\,d\mathcal L^1(p)
=
\int_{[0,\infty)}\mathcal L^1(\{p\in[0,1]:Q_X(p)>t\})\,d\mathcal L^1(t).
\end{align*}
Using the superlevel identity from the previous step gives
\begin{align*}
\int_{[0,1]} Q_X(p)\,d\mathcal L^1(p)
=
\int_{[0,\infty)}\mathbb P(\{\omega\in\Omega:X(\omega)>t\})\,d\mathcal L^1(t).
\end{align*}
Apply the same layer-cake identity to the measure space $(\Omega,\mathcal F,\mathbb P)$ and the measurable function $X:\Omega\to[0,\infty)$. This gives
\begin{align*}
\mathbb E[X]
=
\int_\Omega X(\omega)\,d\mathbb P(\omega)
=
\int_{[0,\infty)}\mathbb P(\{\omega\in\Omega:X(\omega)>t\})\,d\mathcal L^1(t).
\end{align*}
Comparing the two displayed identities yields
\begin{align*}
\mathbb E[X]=\int_{[0,1]} Q_X(p)\,d\mathcal L^1(p).
\end{align*}
All integrals involved are integrals of nonnegative extended-real-valued functions, so the equality is valid even when the common value is $\infty$.
[/step]