I am not sure how you will apply it to 4 numbers but with 2 numbers here's how you might do it-
a+b = n
m(Arithmetic Mean) = (a+b)/2
let d = |a-m| = |b-m|
Without the loss of generality assume a>=b.
So, a = m+d
and b = m-d
Our Goal- Maximise a*b
To Maximise a*b, we need to Maximise (m+d)(m-d)
(m+d)(m-d) = m^2 - d^2 = (n/2)^2 - (d)^2 = n^2/4 - (d)^2
n^2/4 is a constant, we cannot change it by changing the values of a and b.
So we need to Minimise (d)^2. (d)^2 is 0 for d = 0 which is its lowest possible value.
Therefore d = 0.
But a = m + d. So d = a-m.
a - m = 0 implies that a = m.
(a + b)/2 = m
(a+b)/2 = a
a+b = 2a
b = a.