We present the results of a comprehensive study of the chemically peculiar stars HD 5797 and HD 40711. The stars have the same effective temperature, Teff = 8900 K, and a similar chemical composition with large iron (+1.5 dex) and chromium (+3 dex) overabundances compared to the Sun. The overabundance of rare-earth elements typically reaches +3 dex. We have measured the magnetic field of HD 5797. The longitudinal field component Be has been found to vary sinusoidally between -100 and +1000 G with a period of 69 days. Our estimate of the evolutionary status of the stars suggests that HD 5797 and HD 40711, old objects with an age t approx 5 times 108 yr, are near the end of the core hydrogen burning phase.