Spectrum of the cosmic X- and gamma ray background in the energy range 1 keV-1 MeV