Solution (source code)

= Solution

Apply the <monotone convergence theorem> to $s_N=\sum_{k=1}^N|a_k|$. Its limit $s$ satisfies
$$
\int s=\sum_{k=1}^\infty\int|a_k|<\infty.
$$
Thus $s$ is finite almost everywhere, which proves <absolute convergence> of $\sum_k a_k$ almost everywhere. Define its sum $a$ there, and set $a=0$ on the exceptional <null set>. Then $|a|\leq s$, so $a$ is integrable. The partial sums of $\sum_k a_k$ are also dominated by $s$; <dominated convergence theorem>[dominated convergence] gives
$$
\boxed{\int\sum_{k=1}^\infty a_k=\lim_{N\to\infty}\sum_{k=1}^N\int a_k
=\sum_{k=1}^\infty\int a_k.}
$$
The series of integrals converges absolutely, since $|\int a_k|\leq\int|a_k|$.