I understand that physicists can calculate the distance to stars via redshift, ie, relativistic doppler effects. However, unlike sound, photons have higher energies at higher frequencies and lower energies at lower frequencies. My question is, as the photons coming towards us shift red, get lower frequencies and thus lower energies, what happens to the energy that made it higher frequency when it started?