To give you an idea, obviously the value of ai can only be-1, 0, 1, 2.
Let's set X-1, Y- 1 and Z-2.
According to the simultaneous equations of the main conditions, a ternary linear equation group is obtained, while the quadratic equation group has only two equations.
The topic allows you to find the maximum value of the original formula, which can also be expressed by x, y, z, y and z.
You can join the league, but don't talk about it later (note that x, y, z y and z are all positive integers).