Relativistic energies of excited states of atoms and ions of the second period