Electron Density in Metallic Crystal as an Extremal with Moving Boundaries