# To find unique positive integer n for which $S_n$ is integer

For a positive integer $n$, let $S_n$ denote the minimum value of the sum $$\sum_{k=1}^n \sqrt{(2k-1)^2+(a_k)^2}$$ where $a_1,a_2,a_3,....,a_n$ are positive real numbers whose sum is $17$. If there exist a unique positive integer $n$ for which $S_n$ is also an integer. I got the answer as $12$ using some basic arithmetic but I want to know whether there are any other methods to solve like the Cauchy Schwartz Inequality, or the AM-GM inequality. Thanks in advance

$$\sum_{i=1}^n{\sqrt{a_{i}^2 + b_{i}^2}} \ge \sqrt{(\sum_{i=1}^{n}a_i)^2 + (\sum_{i=1}^{n}b_i)^2}$$
Also you can note $\sum_{i=1}^{n} (2i-1) = n^2$ and that should get you there.
Consider $n$ right triangles joined at their vertices, with bases $a_1,a_2,\ldots,a_n$ and heights $1,3,\ldots, 2n - 1$. The sum of their hypotenuses is the value of $S_n$. The minimum value of $S_n$, then, is the length of the straight line connecting the bottom vertex of the first right triangle and the top vertex of the last right triangle, so $$S_n \ge \sqrt {\left(\sum_{k = 1}^n (2k - 1)\right)^2 + \left(\sum_{k = 1}^n a_k\right)^2}.$$Since the sum of the first $n$ odd integers is $n^2$ and the sum of $a_1,a_2,\ldots,a_n$ is 17, we get $$S_n \ge \sqrt {17^2 + n^4}.$$If this is integer, we can write $17^2 + n^4 = m^2$, for an integer $m$. Thus, $(m - n^2)(m + n^2) = 289\cdot 1 = 17\cdot 17 = 1\cdot 289.$ The only possible value, then, for $m$ is $145$, in which case $n^2 = 144$