On build-up of magnetic energy in the solar atmosphere