New expressions for ON and NS calibrations (we call them ON11 and NS11 calibrations) for the determination of oxygen and nitrogen abundances in HII regions are proposed. New criteria for the division of HII regions into three classes (hot, warm, and cold) are also proposed. ON11 and NS11 calibrations provide more accurate determination of oxygen and nitrogen abundances from integrated emission spectra, in comparison with ON and NS calibrations. Oxygen and nitrogen abundances are estimated for a sample of 57 470 SDSS galaxies using ON11 and NS11 calibrations. Strongline flux measurements for SDSS spectra of these galaxies are taken from the MPA/JHU catalog. A “mass-metallicity” diagram for several redshift ranges is constructed. It is found that the interstellar medium of galaxies with high masses log(M/M ⊙) > 11.3 was hardly enriched with either oxygen or nitrogen over the last 4 Gyrs (corresponding to the redshift interval z = 0–0.4). This indicates that an active stage of star formation in massive galaxies was completed more than 4 Gyrs ago. For galaxies of lower masses, changes in oxygen and nitrogen abundances over the time period under consideration increase as galaxy mass decreases.