Analysis of the reaction γ+n→p+π− in the first and second resonance regions