Determination of baryon and baryon-resonance masses from quantum- chromodynamics sum rules. Nonstrange baryons