6. Let's call the distance between numbers the absolute value of their difference. It is known that the sum of the distances from twenty consecutive natural numbers to some number $a$ is 360, and the sum of the distances from these same twenty numbers to the number $a^{2}$ is 345. Find all possible values of $a$.
Answer: $a=-\frac{1}{2}, a=\frac{3}{2}$.

Solution. Let the given consecutive natural numbers be denoted as $k, k+1, \ldots, k+19$. Note that if some number lies on the segment $[k ; k+19]$, then the sum of the distances from it to the given twenty numbers does not exceed $10 \cdot 19=190$ (the sum of the distances to the two extreme numbers is exactly 19, the sum of the distances to $k+1$ and $k+18$ does not exceed 19, the sum of the distances to $k+2$ and $k+17$ also does not exceed 19, and so on). Therefore, the numbers $a$ and $a^{2}$ lie outside the segment $[k ; k+19]$. Then the sum of the distances from the number $a$ to each of the given consecutive numbers is expressed by the formula $|20 a-k-(k+1)-\ldots-(k+19)|=|20 a-20 k-190|$. Similarly, the sum of the distances from the number $a^{2}$ to each of the given numbers is equal to $\left|20 a^{2}-20 k-190\right|$. We obtain the system of equations

$$
\left\{\begin{array} { l } 
{ | 2 0 a ^ { 2 } - 2 0 k - 1 9 0 | = 3 4 5 , } \\
{ | 2 0 a - 2 0 k - 1 9 0 | = 3 6 0 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
\left|a^{2}-k-9.5\right|=17.25 \\
|a-k-9.5|=18
\end{array}\right.\right.
$$

Consider four cases of opening the modulus.

1) Both numbers $a$ and $a^{2}$ lie to the right of the segment $[k ; k+19]$. Then

$$
\left\{\begin{array} { l } 
{ a ^ { 2 } - k - 9 , 5 = 1 7 , 2 5 , } \\
{ a - k - 9 , 5 = 1 8 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
a-k-9.5=18 \\
a^{2}-a+0.75=0
\end{array}\right.\right.
$$

The discriminant of the quadratic equation is negative, so there are no solutions.

2) Both numbers $a$ and $a^{2}$ lie to the left of the segment $[k ; k+19]$. Then

$$
\left\{\begin{array} { l } 
{ k + 9 , 5 - a ^ { 2 } = 1 7 , 2 5 , } \\
{ k + 9 , 5 - a = 1 8 }
\end{array} \Leftrightarrow \left\{\begin{array} { l } 
{ k + 9 , 5 - a = 1 8 , } \\
{ a ^ { 2 } - a - 0 , 7 5 = 0 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
k=a+8.5 \\
{\left[\begin{array}{l}
a=-0.5 \\
a=1.5
\end{array}\right.}
\end{array}\right.\right.\right.
$$

We verify that for both values of $a$, the number $k$ is a natural number ($a=-0.5 \Rightarrow k=8$; $a=1.5 \Rightarrow k=10$), so both values of $a$ are valid.

3) The number $a$ lies to the left, and $a^{2}$ to the right of the segment $[k ; k+19]$. Then

$$
\left\{\begin{array} { l } 
{ a ^ { 2 } - k - 9 , 5 = 1 7 , 2 5 , } \\
{ k + 9 , 5 - a = 1 8 }
\end{array} \Leftrightarrow \left\{\begin{array} { l } 
{ k + 9 , 5 - a = 1 8 , } \\
{ a ^ { 2 } - a - 3 5 , 2 5 = 0 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
k=a+8.5 \\
a=\frac{1 \pm \sqrt{142}}{2}
\end{array}\right.\right.\right.
$$

Then from the first equation of the system it follows that $k$ is an irrational number, which does not satisfy the condition of the problem.

4) The number $a$ lies to the right, and $a^{2}$ to the left of the segment $[k ; k+19]$. Obviously, this case does not fit, because if $a>a^{2}$, then both numbers $a$ and $a^{2}$ lie on the segment $[0 ; 1]$, but then there cannot be any integer between them.

Thus, there are two possible cases: $a=-0.5$ and $a=1.5$.