## Algorithm for constructing the subsoil density distribution function considering its value on the surface

The conventional approach to constructing a three-dimensional distribution of the Earth's masses involves using Stokes constants incrementally up to a certain order. However, this study proposes an algorithm that simultaneously considers all of these constants, which could potentially provide a more efficient method. The basis for this is a system of equations obtained by differentiating the Lagrange function, which takes into account the minimum deviation of the three-dimensional mass distribution of the planet's subsoil from one-dimensional referential one.