Researched Spells Upon Leveling
At every level after first, a Wizard or Elf can spend 25 GP per spell level to retroactively have been researching a spell, which you then acquire upon attaining the level. The new spell must be of a level must you were able to cast at the previous level, representing the limits of your knowledge until very recently.
Thus, at 2nd and 3rd levels, you can have been researching a new 1st level spell at the cost of 25 GP, but not until 4th level, when you’ve had access to 2nd level spells, can you level up and attain a 2nd level spell by retroactive research, at the cost of 50 GP.
This spell is learned automatically, and the Learning a new Spell rule does not apply.