12.57 For a positive integer $n$, let $S_{n}$ be the minimum value of $\sum_{k=1}^{n} \sqrt{(2 k-1)^{2}+a_{k}^{2}}$, where $a_{1}, a_{2}, \cdots, a_{n}$ are positive real numbers whose sum is 17. There is a unique $n$ for which $S_{n}$ is also an integer. Find $n$.
(9th American Invitational Mathematics Examination, 1991)
[Solution] Consider each term $t_{k}=\sqrt{(2 k-1)^{2}+a_{k}^{2}}$ as the hypotenuse of a right-angled triangle, with the two legs being $2 k-1$ and $a_{k}$.

By placing these right-angled triangles together to form a ladder, let $A, B$ be the starting and ending points, respectively.
The distance from $A$ to $B$ is
$$
\sqrt{\left(\sum_{k=1}^{n} a_{k}\right)^{2}+\left[\sum_{k=1}^{n}(2 k-1)\right]^{2}}=\sqrt{17^{2}+n^{4}} \text {. }
$$

The sum $\sum_{k=1}^{n} t_{k}$ represents the length of the path from $A$ to $B$ along the hypotenuses, so
$$
\sum_{k=1}^{n} t_{k} \geqslant \sqrt{17^{2}+n^{4}}
$$

and we can choose $a_{k}$ such that the equality holds.
Thus,
$$
S_{n}=\sqrt{17^{2}+n^{4}} \text {. }
$$

When $S_{n}$ is an integer, we seek the positive integer solutions to
$$
S_{n}^{2}=17^{2}+n^{4}
$$
$$
17^{2}=S_{n}^{2}-n^{4}=\left(S_{n}-n^{2}\right)\left(S_{n}+n^{2}\right) .
$$

Since 17 is a prime number, we have
$$
\left\{\begin{array}{l}
S_{n}-n^{2}=1 \\
S_{n}+n^{2}=17^{2}
\end{array}\right.
$$

Solving these equations, we get
$$
S_{n}=145, \quad n=12 .
$$