Let the side of the square base be x, and the height of the box be h.
The material of the base is x^2, and the material of the four sides is 4xh.
4000 = hx^2
h = 4000/x^2
The total material is
M = x^2 + 4x(4000/x^2) = x^2 + 16000/x
Take the first derivative of M and set equal to 0.
M' = 2x - 16000/x^2 = 0
Multiply by x^2:
2x^3 = 16000
x^3 = 8000
x = 20; h = 10; M = 1200