Pregunta de entrevista de Metropolis

Smashing stones problem. There is an array with stones of various weights. Take the highest and second highest weighted stone, find the diff add it back to the array. Keep doing it till one element left and output it.