It's often helpful to draw a diagram showing the energy levels for the particular element you're interested in. The diagram for hydrogen is shown above.
The n = 1 state is known as the ground state, while higher n states are known as excited states. If the electron in the atom makes a transition from a particular state to a lower state, it is losing energy. To conserve energy, a photon with an energy equal to the energy difference between the states will be emitted by the atom.
Consider the photon emitted when an electron drops from the n=4 to the n=2 state to the photon emitted when an electron drops from n=3 to n=2. Which photon has the longer wavelength?
The photon emitted in the n=4 to n=2 transition
The photon emitted in the n=3 to n=2 transition
The smaller the energy the longer the wavelength. The photon has a smaller energy for the n=3 to n=2 transition.
In the hydrogen atom, with Z = 1, the energy of the emitted photon can be found using:
E = (13.6 eV) [1/nf2 - 1/ni2]
Atoms can also absorb photons. If a photon with an energy equal to the energy difference between two levels is incident on an atom, the photon can be absorbed, raising the electron up to the higher level.