5. Given that $a, b, c$ are distinct positive integers such that
$$
\{a+b, b+c, c+a\}=\left\{n^{2},(n+1)^{2},(n+2)^{2}\right\} \text {, }
$$

where $n$ is a positive integer. Then the minimum value of $a^{2}+b^{2}+c^{2}$ is
$\qquad$
5. 1297.
Let $a>b>c$. From
$$
(a+b)+(b+c)+(c+a)=2(a+b+c)
$$

we know it is an even number, so $\left\{n^{2},(n+1)^{2},(n+2)^{2}\right\}$ contains two odd squares and one even square. Therefore, $n$ is an odd number.
Since $b+c>1$, then $n>1$.
If $n=3$, then
$$
\left\{n^{2},(n+1)^{2},(n+2)^{2}\right\}=\left\{3^{2}, 4^{2}, 5^{2}\right\},
$$

and by $50=3^{2}+4^{2}+5^{2}=2(a+b+c)$
$$
\Rightarrow a+b+c=25 \text {. }
$$

The largest square number $a+b=5^{2} \Rightarrow c=0$, which does not meet the condition.
If $n=5$, then
$$
\begin{array}{l}
\left\{n^{2},(n+1)^{2},(n+2)^{2}\right\}=\left\{5^{2}, 6^{2}, 7^{2}\right\} \\
\Rightarrow a=30, b=19, c=6 .
\end{array}
$$

Thus, $a^{2}+b^{2}+c^{2}=30^{2}+19^{2}+6^{2}=1297$.