Formation of the 0.511.-MeV line in solar flares. [statistical mechanics of line spectra for gamma rays