Rigidity dependence of cosmic-ray escape length obtained from a comparison of proton and iron spectra in the energy range 3–3000 GeV