Is there a better way to solve this problem? A question from the 24th PMO For context, this contest was held today. And for transparency, I was one of the participants. This is Problem 16 from the 24th Philippine Mathematical Olympiad. :

What is the largest multiple of $7$ less than $10000$ which can be represented as the sum of squares of three consecutive numbers?

I got the correct answer, which is $8750$.

We can let the sum of the squares of the three consecutive numbers as \begin{align*}S &= (a - 1)^2 + a^2 + (a + 1)^2\\ S &= a^2 - 2a + 1 + a^2 + a^2 + 2a + 1 \\ S &= 3a^2 + 2\end{align*} Here, $a$ is the middle number.
Clearly, the lower bound of $a$ is $14$ since the second smallest integer is $2$, and $1^2 + 2^2 + 3^2 = 14$. Solving for the upper bound,
\begin{align*}
3a^2 + 2 &\leq 10000 \\
3a^2 &\leq 9998 \\
a^2 &\leq 3332.\bar{6}
\end{align*}
By trial-and-error, the greatest square less than or equal to $3332.\bar{6}$ is $57^2$. Hence, $2 \leq a \leq 57$.
From the statement, we must have
\begin{align*}
(3a^2 + 2) &\equiv 0 \bmod 7 \\
3a^2 &\equiv 5 \bmod 7 \\
a^2 &\equiv 4 \bmod 7
\end{align*}
Evaluating $i^2$ for $i \in \{0, 1, \ldots, 6\}$, we can see that the applicable values are $\{2, 5\}$. Hence, the value of $a^2$ must be a multiple of $2$ or $5$, but not both. Luckily, the last numbers are multiples of $2$ or $5$, and trying the last three, we have
\begin{align*}
56^2 &\equiv 0 \bmod 7 \\
55^2 &\equiv 1 \bmod 7 \\
54^2 &\equiv 4 \bmod 7
\end{align*}
This means that what we are looking for is $a = 54$. Solving for $S$,
\begin{align*}
S &= 3a^2 + 2 \\
S &= 3\cdot 54^2 + 2 \\
S &= 3 \cdot 2916 + 2 \\
S &= 8748 + 2 \\
S &= 8750
\end{align*}
Therefore, the largest multiple of $7$ less than $10000$ which can be represented as the sum of squares of three consecutive numbers is $8750$.

Can I ask how to shorten this proof, if this can be shorted?
Edit(s):

*

*The expression $a$ is replaced with $a^2$ in this part:


Hence, the value of $a$ must be a multiple of $2$ or $5$, but not both.

which becomes

Hence, the value of $a^2$ must be a multiple of $2$ or $5$, but not both.


To summarize the discussion in the comments:
The OP's solution contains an error which doesn't impact the final result.  Specifically, the solution for $a$ ought to be $a\equiv \pm 2 \pmod 7$, not "multiples of $2$ or $5$".  This doesn't matter in the end, because the OP only ends up looking at $a^2$ anyway, so never uses the incorrect computation of $a$.
For a shorter argument which avoids serious trial and error:  Use the fact that $a≤57$.  Then, using the correct solution, $a\equiv \pm 2\pmod 7$ we see that we are looking for the largest number $≤57$ which has the form $7n+2$ or $7n-2$.  Inspection shows that $56-2=54$ is the largest such, and we are done.
