A new model for the distribution of flare energies