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-nine consecutive natural numbers to some number $a$ is 1624, and the sum of the distances from these same twenty-nine numbers to some number $b$ is 1305. Find all possible values of $a$, given that $a+b=115$.
Answer: $a=52, a=108, a=7$.

Solution. Let the given sequence of natural numbers be denoted as $k, k+1, \ldots, k+28$. Notice that if some number lies on the interval $[k ; k+28]$, then the sum of the distances from it to the given twenty-nine numbers does not exceed $\frac{29}{2} \cdot 28=406$ (the sum of the distances to the two extreme numbers is exactly 28, the sum of the distances to $k+1$ and $k+27$ does not exceed 28, the sum of the distances to $k+2$ and $k+26$ also does not exceed 28, and so on; the distance to $k+14$ does not exceed half the length of the interval between the extreme numbers, i.e., 14). Therefore, the numbers $a$ and $b$ lie outside the interval $[k ; k+28]$. Then the sum of the distances from the number $a$ to each of the given consecutive numbers is expressed by the formula $|29 a-k-(k+1)-\ldots-(k+28)|=29|a-k-14|$. Similarly, the sum of the distances from the number $b$ to each of the given numbers is $29|b-k-14|$. We obtain the system of equations

$$
\left\{\begin{array} { l } 
{ 2 9 | a - k - 1 4 | = 1 6 2 4 , } \\
{ 2 9 | b - k - 1 4 | = 1 3 0 5 , } \\
{ a + b = 1 1 5 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
|a-k-14|=56 \\
|b-k-14|=45 \\
a+b=115
\end{array}\right.\right.
$$

Consider four cases for the removal of the modulus.

1) Both numbers $a$ and $b$ lie to the right of the interval $[k ; k+28]$. Then

$$
\left\{\begin{array} { l } 
{ a - k - 1 4 = 5 6 , } \\
{ b - k - 1 4 = 4 5 , } \\
{ a + b = 1 1 5 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
a=63 \\
b=52 \\
k=-7
\end{array}\right.\right.
$$

Since $k$ must be a natural number, this case does not fit.

2) Both numbers $a$ and $b$ lie to the left of the interval $[k ; k+28]$. Then

$$
\left\{\begin{array} { l } 
{ - a + k + 1 4 = 5 6 , } \\
{ - b + k + 1 4 = 4 5 , } \\
{ a + b = 1 1 5 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
a=52 \\
b=63 \\
k=94
\end{array}\right.\right.
$$

3) The number $a$ lies to the right, and $b$ - to the left of the interval $[k ; k+28]$. Then

$$
\left\{\begin{array} { l } 
{ a - k - 1 4 = 5 6 , } \\
{ - b + k + 1 4 = 4 5 , } \\
{ a + b = 1 1 5 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
a=108 \\
b=7 \\
k=38
\end{array}\right.\right.
$$

4) The number $b$ lies to the right, and $a$ - to the left of the interval $[k ; k+28]$. Then

$$
\left\{\begin{array} { l } 
{ - a + k + 1 4 = 5 6 , } \\
{ b - k - 1 4 = 4 5 , } \\
{ a + b = 1 1 5 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
a=7 \\
b=108 \\
k=49
\end{array}\right.\right.
$$

Thus, there are three possible cases: $a=52, a=108, a=7$.