A result of reconstruction of velocities of elastic waves and boundaries of thin layers in a thinly stratified stack is presented. For this purpose, the method of residual functional minimization is used. Differentiation of the residual functional with respect to coordinates of gap points of a medium is proved and the appropriate derivative is obtained.