In this paper, an algorithm for solving boundary value problems of elasticity theory suitable for solving contact problems and those whose deformation domain contains thin layers is presented. The solution is represented as a linear combination of auxiliary and fundamental solutions to the Lame equations. The singular points of the fundamental solutions are located in an outer layer of the deformation domain near the boundary. The linear combination coefficients are determined by minimizing deviations of the linear combination from the boundary conditions. To minimize the deviations, a conjugate gradient method is used. Examples of calculations for mixed boundary conditions are presented.