Solution (source code)

= Solution

Expand around the <expectation> $\mu$:
$$
G(a)=\mathbb E[(X-\mu)^2]+2(\mu-a)\mathbb E[X-\mu]+(\mu-a)^2
=\sigma^2+(\mu-a)^2.
$$
Thus <variance as the minimum mean squared error of a constant> gives
$$
\boxed{G(a)\geq\sigma^2,\quad\text{with equality exactly at }a=\mu}.
$$
The finite <second moment> also guarantees the finite first absolute moment needed below.

For a <probability density function> $f$, splitting at $a$ gives
$$
H(a)=\int_{-\infty}^a(a-x)f(x)\,dx+
\int_a^\infty(x-a)f(x)\,dx.
$$
Let $F$ be the <cumulative distribution function>. Since a density gives no mass at a singleton, differentiating under this integral yields $H'(a)=F(a)-(1-F(a))=2F(a)-1$. This <derivative> is nondecreasing, so $H$ is <convex> and
$$
\boxed{H\text{ is minimized at every }a\text{ with }F(a)=\frac12}.
$$
This is the <median minimizes expected absolute loss> property. The minimizer need not be unique: a gap in the density can give an interval of <medians>, all with the same loss.