Context : High spectral resolution studies of cool Ap stars reveal conspicuous anomalies of the shape and strength of many absorption lines . This is a signature of large atmospheric chemical gradients ( chemical stratification ) produced by the selective radiative levitation and gravitational settling of chemical species . Aims : Previous observational studies of the chemical stratification in Ap stars were limited to fitting simple parametrized chemical profiles . Here we present a new approach to mapping the vertical chemical structures in stellar atmospheres . Methods : We have developed a regularized chemical inversion procedure that uses all information available in high-resolution stellar spectra . The new technique for the first time allowed us to recover chemical profiles without making a priori assumptions about the shape of chemical distributions . We have derived average abundances and applied the vertical inversion procedure to the high-resolution VLT UVES spectra of the weakly magnetic , cool Ap star HD 133792 . Results : Our spectroscopic analysis yielded improved estimates of the atmospheric parameters of HD 133792 . We show that this star has negligible v _ { e } \sin i and the mean magnetic field modulus \langle B \rangle = 1.1 \pm 0.1 kG . We have derived average abundances for 43 ions and obtained vertical distributions of Ca , Si , Mg , Fe , Cr , and Sr. All these elements except Mg show high overabundance in the deep layers and solar or sub-solar composition in the upper atmosphere of HD 133792 . In contrast , the Mg abundance increases with height . Conclusions : We find that transition from the metal-enhanced to metal-depleted zones typically occurs in a rather narrow range of depths in the atmosphere of HD 133792 . Based on the derived photospheric abundances , we conclude that HD 133792 belongs to the rare group of evolved cool Ap stars , which possesses very large Fe-peak enhancement , but lacks a prominent overabundance of the rare-earth elements .